Replace #[cfg(unix)] with #[cfg(any(target_os = "android", target_os = "linux"))]

Updates are made to source and documentation.

This more accurately represents the currently supported platforms of
Android/Linux and Windows, without unexpectedly including other
unix-like operating systems.

Command to reproduce:
$ find . -type f -not -path '*/\.git/*' | xargs -I {} sed -i 's/cfg(unix)/cfg(any(target_os = "android", target_os = "linux"))/g' {}
$ cargo fmt

md files manually updated to fix line lengths.

Renaming `unix` modules to `linux` will be done in a later CL.

Test: ./tools/dev_container ./tools/presubmit
Bug: b/298269162
Change-Id: I42c1bf0abf80b9a0df25551613910293217c7295
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4909059
Commit-Queue: Cody Schuffelen <schuffelen@google.com>
Reviewed-by: Frederick Mayle <fmayle@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 2221cd1..0827463 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -41,8 +41,9 @@
 ```
 devices: vhost: user: vmm: Add Connection type
 
-This abstracts away the cross-platform differences: cfg(unix) uses a
-Unix domain stream socket to connect to the vhost-user backend, and
+This abstracts away the cross-platform differences:
+cfg(any(target_os = "android", target_os = "linux")) uses a Unix
+domain domain stream socket to connect to the vhost-user backend, and
 cfg(windows) uses a Tube.
 
 BUG=b:249361790
diff --git a/Cargo.toml b/Cargo.toml
index c7f5bf7..0c48ed3 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -453,7 +453,7 @@
 [target.'cfg(any(target_arch = "aarch64", target_arch = "arm"))'.dependencies]
 aarch64 = { path = "aarch64" }
 
-[target.'cfg(unix)'.dependencies]
+[target.'cfg(any(target_os = "android", target_os = "linux"))'.dependencies]
 minijail = "*" # provided by ebuild
 p9 = "0.2.3"
 vhost = { path = "vhost" }
diff --git a/aarch64/Cargo.toml b/aarch64/Cargo.toml
index 51f8244..7339598 100644
--- a/aarch64/Cargo.toml
+++ b/aarch64/Cargo.toml
@@ -31,5 +31,5 @@
 vm_control = { path = "../vm_control" }
 vm_memory = { path = "../vm_memory" }
 
-[target.'cfg(unix)'.dependencies]
+[target.'cfg(any(target_os = "android", target_os = "linux"))'.dependencies]
 minijail = "*"
diff --git a/aarch64/src/lib.rs b/aarch64/src/lib.rs
index fd8e50c..ae86477 100644
--- a/aarch64/src/lib.rs
+++ b/aarch64/src/lib.rs
@@ -55,13 +55,13 @@
 #[cfg(windows)]
 use jail::FakeMinijailStub as Minijail;
 use kernel_loader::LoadedKernel;
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 use minijail::Minijail;
 use remain::sorted;
 use resources::AddressRange;
 use resources::SystemAllocator;
 use resources::SystemAllocatorConfig;
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 use sync::Condvar;
 use sync::Mutex;
 use thiserror::Error;
@@ -392,7 +392,9 @@
         dump_device_tree_blob: Option<PathBuf>,
         _debugcon_jail: Option<Minijail>,
         #[cfg(feature = "swap")] swap_controller: &mut Option<swap::SwapController>,
-        #[cfg(unix)] _guest_suspended_cvar: Option<Arc<(Mutex<bool>, Condvar)>>,
+        #[cfg(any(target_os = "android", target_os = "linux"))] _guest_suspended_cvar: Option<
+            Arc<(Mutex<bool>, Condvar)>,
+        >,
     ) -> std::result::Result<RunnableLinuxVm<V, Vcpu>, Self::Error>
     where
         V: VmAArch64,
diff --git a/arch/Cargo.toml b/arch/Cargo.toml
index e553772..bb00015 100644
--- a/arch/Cargo.toml
+++ b/arch/Cargo.toml
@@ -36,7 +36,7 @@
 vm_control = { path = "../vm_control" }
 vm_memory = { path = "../vm_memory" }
 
-[target.'cfg(unix)'.dependencies]
+[target.'cfg(any(target_os = "android", target_os = "linux"))'.dependencies]
 minijail = "*" # provided by ebuild
 power_monitor = { path = "../power_monitor" }
 
diff --git a/arch/src/lib.rs b/arch/src/lib.rs
index cf1a059..2d85b51 100644
--- a/arch/src/lib.rs
+++ b/arch/src/lib.rs
@@ -51,7 +51,7 @@
 use devices::PciRoot;
 use devices::PciRootCommand;
 use devices::PreferredIrq;
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 use devices::ProxyDevice;
 use devices::SerialHardware;
 use devices::SerialParameters;
@@ -62,7 +62,7 @@
 use hypervisor::Vm;
 #[cfg(windows)]
 use jail::FakeMinijailStub as Minijail;
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 use minijail::Minijail;
 use remain::sorted;
 #[cfg(target_arch = "x86_64")]
@@ -78,7 +78,7 @@
 pub use serial::set_default_serial_parameters;
 pub use serial::GetSerialCmdlineError;
 pub use serial::SERIAL_ADDR;
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 use sync::Condvar;
 use sync::Mutex;
 use thiserror::Error;
@@ -373,7 +373,7 @@
     pub mmio_bus: Arc<Bus>,
     pub no_smt: bool,
     pub pid_debug_label_map: BTreeMap<u32, String>,
-    #[cfg(unix)]
+    #[cfg(any(target_os = "android", target_os = "linux"))]
     pub platform_devices: Vec<Arc<Mutex<dyn BusDevice>>>,
     pub pm: Option<Arc<Mutex<dyn PmResource + Send>>>,
     /// Devices to be notified before the system resumes from the S3 suspended state.
@@ -460,7 +460,9 @@
         #[cfg(target_arch = "x86_64")] pflash_jail: Option<Minijail>,
         #[cfg(target_arch = "x86_64")] fw_cfg_jail: Option<Minijail>,
         #[cfg(feature = "swap")] swap_controller: &mut Option<swap::SwapController>,
-        #[cfg(unix)] guest_suspended_cvar: Option<Arc<(Mutex<bool>, Condvar)>>,
+        #[cfg(any(target_os = "android", target_os = "linux"))] guest_suspended_cvar: Option<
+            Arc<(Mutex<bool>, Condvar)>,
+        >,
     ) -> std::result::Result<RunnableLinuxVm<V, Vcpu>, Self::Error>
     where
         V: VmArch,
@@ -493,7 +495,7 @@
     fn register_pci_device<V: VmArch, Vcpu: VcpuArch>(
         linux: &mut RunnableLinuxVm<V, Vcpu>,
         device: Box<dyn PciDevice>,
-        #[cfg(unix)] minijail: Option<Minijail>,
+        #[cfg(any(target_os = "android", target_os = "linux"))] minijail: Option<Minijail>,
         resources: &mut SystemAllocator,
         hp_control_tube: &mpsc::Sender<PciRootCommand>,
         #[cfg(feature = "swap")] swap_controller: &mut Option<swap::SwapController>,
@@ -569,14 +571,14 @@
     #[error("Allocating IRQ number")]
     AllocateIrq,
     /// Could not allocate IRQ resource for the device.
-    #[cfg(unix)]
+    #[cfg(any(target_os = "android", target_os = "linux"))]
     #[error("Allocating IRQ resource: {0}")]
     AllocateIrqResource(devices::vfio::VfioError),
     /// Broken pci topology
     #[error("pci topology is broken")]
     BrokenPciTopology,
     /// Unable to clone a jail for the device.
-    #[cfg(unix)]
+    #[cfg(any(target_os = "android", target_os = "linux"))]
     #[error("failed to clone jail: {0}")]
     CloneJail(minijail::Error),
     /// Appending to kernel command line failed.
@@ -615,11 +617,11 @@
     /// Failed to insert device into PCI root.
     #[error("failed to insert device into PCI root: {0}")]
     PciRootAddDevice(PciDeviceError),
-    #[cfg(unix)]
+    #[cfg(any(target_os = "android", target_os = "linux"))]
     /// Failed to initialize proxy device for jailed device.
     #[error("failed to create proxy device: {0}")]
     ProxyDeviceCreation(devices::ProxyError),
-    #[cfg(unix)]
+    #[cfg(any(target_os = "android", target_os = "linux"))]
     /// Failed to register battery device.
     #[error("failed to register battery device to VM: {0}")]
     RegisterBattery(devices::BatteryError),
@@ -644,7 +646,7 @@
 pub fn configure_pci_device<V: VmArch, Vcpu: VcpuArch>(
     linux: &mut RunnableLinuxVm<V, Vcpu>,
     mut device: Box<dyn PciDevice>,
-    #[cfg(unix)] jail: Option<Minijail>,
+    #[cfg(any(target_os = "android", target_os = "linux"))] jail: Option<Minijail>,
     resources: &mut SystemAllocator,
     hp_control_tube: &mpsc::Sender<PciRootCommand>,
     #[cfg(feature = "swap")] swap_controller: &mut Option<swap::SwapController>,
@@ -704,7 +706,7 @@
         .register_device_capabilities()
         .map_err(DeviceRegistrationError::RegisterDeviceCapabilities)?;
 
-    #[cfg(unix)]
+    #[cfg(any(target_os = "android", target_os = "linux"))]
     let arced_dev: Arc<Mutex<dyn BusDevice>> = if let Some(jail) = jail {
         let proxy = ProxyDevice::new(
             device,
@@ -729,7 +731,7 @@
         Arc::new(Mutex::new(device))
     };
 
-    #[cfg(unix)]
+    #[cfg(any(target_os = "android", target_os = "linux"))]
     hp_control_tube
         .send(PciRootCommand::Add(pci_address, arced_dev.clone()))
         .map_err(DeviceRegistrationError::RegisterDevice)?;
@@ -768,7 +770,7 @@
     #[cfg(target_arch = "x86_64")]
     let mut sdts = sdts;
     for dev_value in devices.into_iter() {
-        #[cfg(unix)]
+        #[cfg(any(target_os = "android", target_os = "linux"))]
         let (mut device, jail) = dev_value;
         #[cfg(windows)]
         let (mut device, _) = dev_value;
@@ -805,7 +807,7 @@
                 .ok_or(DeviceRegistrationError::GenerateAcpi)?;
         }
 
-        #[cfg(unix)]
+        #[cfg(any(target_os = "android", target_os = "linux"))]
         let arced_dev: Arc<Mutex<dyn BusDevice>> = if let Some(jail) = jail {
             let proxy = ProxyDevice::new(
                 device,
@@ -1088,7 +1090,7 @@
     let mut amls = BTreeMap::new();
     let mut gpe_scope_amls = BTreeMap::new();
     for (dev_idx, dev_value) in devices {
-        #[cfg(unix)]
+        #[cfg(any(target_os = "android", target_os = "linux"))]
         let (mut device, jail) = dev_value;
         #[cfg(windows)]
         let (mut device, _) = dev_value;
@@ -1121,7 +1123,7 @@
         }
         let gpe_nr = device.set_gpe(resources);
 
-        #[cfg(unix)]
+        #[cfg(any(target_os = "android", target_os = "linux"))]
         let arced_dev: Arc<Mutex<dyn BusDevice>> = if let Some(jail) = jail {
             let proxy = ProxyDevice::new(
                 device,
diff --git a/arch/src/pstore/sys.rs b/arch/src/pstore/sys.rs
index 230cea3..d5cdf60 100644
--- a/arch/src/pstore/sys.rs
+++ b/arch/src/pstore/sys.rs
@@ -3,7 +3,7 @@
 // found in the LICENSE file.
 
 cfg_if::cfg_if! {
-    if #[cfg(unix)] {
+    if #[cfg(any(target_os = "android", target_os = "linux"))] {
         pub(crate) mod unix;
         use unix as platform;
     } else if #[cfg(windows)] {
diff --git a/arch/src/serial.rs b/arch/src/serial.rs
index 1062730..f46292a 100644
--- a/arch/src/serial.rs
+++ b/arch/src/serial.rs
@@ -17,7 +17,7 @@
 use jail::read_jail_addr;
 #[cfg(windows)]
 use jail::FakeMinijailStub as Minijail;
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 use minijail::Minijail;
 use remain::sorted;
 use thiserror::Error as ThisError;
@@ -123,7 +123,7 @@
             .create_serial_device::<Serial>(protection_type, com_evt, &mut preserved_descriptors)
             .map_err(DeviceRegistrationError::CreateSerialDevice)?;
 
-        #[cfg(unix)]
+        #[cfg(any(target_os = "android", target_os = "linux"))]
         let serial_jail = if let Some(serial_jail) = serial_jail.as_ref() {
             let jail_clone = serial_jail
                 .try_clone()
diff --git a/arch/src/serial/sys.rs b/arch/src/serial/sys.rs
index 24c77eb..2c81acb 100644
--- a/arch/src/serial/sys.rs
+++ b/arch/src/serial/sys.rs
@@ -3,7 +3,7 @@
 // found in the LICENSE file.
 
 cfg_if::cfg_if! {
-    if #[cfg(unix)] {
+    if #[cfg(any(target_os = "android", target_os = "linux"))] {
         pub(crate) mod unix;
         use unix as platform;
     } else if #[cfg(windows)] {
diff --git a/arch/src/sys.rs b/arch/src/sys.rs
index d39fc48..46aae60 100644
--- a/arch/src/sys.rs
+++ b/arch/src/sys.rs
@@ -3,7 +3,7 @@
 // found in the LICENSE file.
 
 cfg_if::cfg_if! {
-    if #[cfg(unix)] {
+    if #[cfg(any(target_os = "android", target_os = "linux"))] {
         pub mod unix;
     }
 }
diff --git a/arch/src/sys/unix.rs b/arch/src/sys/unix.rs
index 457dca8..cd91e0c 100644
--- a/arch/src/sys/unix.rs
+++ b/arch/src/sys/unix.rs
@@ -124,7 +124,7 @@
 }
 
 /// Creates a platform device for use by this Vm.
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 pub fn generate_platform_bus(
     devices: Vec<(VfioPlatformDevice, Option<Minijail>)>,
     irq_chip: &mut dyn IrqChip,
diff --git a/audio_streams_conformance_test/Cargo.toml b/audio_streams_conformance_test/Cargo.toml
index 16d2640..e3ea89b 100644
--- a/audio_streams_conformance_test/Cargo.toml
+++ b/audio_streams_conformance_test/Cargo.toml
@@ -19,5 +19,5 @@
 serde_json = "*"
 thiserror = "1.0.20"
 
-[target.'cfg(unix)'.dependencies]
+[target.'cfg(any(target_os = "android", target_os = "linux"))'.dependencies]
 minijail = "*"
diff --git a/audio_streams_conformance_test/src/sys/mod.rs b/audio_streams_conformance_test/src/sys/mod.rs
index a4d9e07..c98396c 100644
--- a/audio_streams_conformance_test/src/sys/mod.rs
+++ b/audio_streams_conformance_test/src/sys/mod.rs
@@ -3,7 +3,7 @@
 // found in the LICENSE file.
 
 cfg_if::cfg_if! {
-    if #[cfg(unix)] {
+    if #[cfg(any(target_os = "android", target_os = "linux"))] {
         mod unix;
         use unix as platform;
     } else if #[cfg(windows)] {
diff --git a/base/Cargo.toml b/base/Cargo.toml
index 963d946..527a385 100644
--- a/base/Cargo.toml
+++ b/base/Cargo.toml
@@ -41,7 +41,7 @@
 libtest-mimic = "0.6"
 protos = { path = "../protos", features = ["composite-disk"] }
 
-[target.'cfg(unix)'.dependencies]
+[target.'cfg(any(target_os = "android", target_os = "linux"))'.dependencies]
 minijail = "*"
 
 [target.'cfg(windows)'.dependencies]
diff --git a/base/src/lib.rs b/base/src/lib.rs
index a741f6c..ae5b8bd 100644
--- a/base/src/lib.rs
+++ b/base/src/lib.rs
@@ -75,7 +75,7 @@
 // TODO(b/233233301): reorganize platform specific exports under platform
 // namespaces instead of exposing them directly in base::.
 cfg_if::cfg_if! {
-    if #[cfg(unix)] {
+    if #[cfg(any(target_os = "android", target_os = "linux"))] {
         pub use sys::unix;
 
         pub use unix::net;
diff --git a/base/src/shm.rs b/base/src/shm.rs
index 124f6eb..ef63a49 100644
--- a/base/src/shm.rs
+++ b/base/src/shm.rs
@@ -74,7 +74,7 @@
         self.size()
     }
 
-    #[cfg(unix)]
+    #[cfg(any(target_os = "android", target_os = "linux"))]
     fn as_raw_fd(&self) -> RawDescriptor {
         self.as_raw_descriptor()
     }
diff --git a/base/src/sys.rs b/base/src/sys.rs
index 6159768..017a477 100644
--- a/base/src/sys.rs
+++ b/base/src/sys.rs
@@ -2,14 +2,14 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 pub mod unix;
 
 #[cfg(windows)]
 pub mod windows;
 
 cfg_if::cfg_if! {
-    if #[cfg(unix)] {
+    if #[cfg(any(target_os = "android", target_os = "linux"))] {
         pub use unix as platform;
         pub use platform::*;
     } else if #[cfg(windows)] {
diff --git a/base/src/tube.rs b/base/src/tube.rs
index 57a2a7d..56a8479 100644
--- a/base/src/tube.rs
+++ b/base/src/tube.rs
@@ -120,7 +120,7 @@
     #[cfg(windows)]
     #[error("failed to flush named pipe: {0}")]
     Flush(io::Error),
-    #[cfg(unix)]
+    #[cfg(any(target_os = "android", target_os = "linux"))]
     #[error("byte framing mode is not supported")]
     InvalidFramingMode,
     #[error("failed to serialize/deserialize json from packet: {0}")]
diff --git a/base/tests/process.rs b/base/tests/process.rs
index b7fc823..c02be66 100644
--- a/base/tests/process.rs
+++ b/base/tests/process.rs
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 mod test {
     use std::thread;
     use std::time::Duration;
@@ -108,27 +108,27 @@
     };
 
     let tests = vec![
-        #[cfg(unix)]
+        #[cfg(any(target_os = "android", target_os = "linux"))]
         libtest_mimic::Trial::test("pid_diff", move || {
             test::pid_diff();
             Ok(())
         }),
-        #[cfg(unix)]
+        #[cfg(any(target_os = "android", target_os = "linux"))]
         libtest_mimic::Trial::test("thread_name", move || {
             test::thread_name();
             Ok(())
         }),
-        #[cfg(unix)]
+        #[cfg(any(target_os = "android", target_os = "linux"))]
         libtest_mimic::Trial::test("thread_name_trimmed", move || {
             test::thread_name_trimmed();
             Ok(())
         }),
-        #[cfg(unix)]
+        #[cfg(any(target_os = "android", target_os = "linux"))]
         libtest_mimic::Trial::test("wait_for_success", move || {
             test::wait_for_success();
             Ok(())
         }),
-        #[cfg(unix)]
+        #[cfg(any(target_os = "android", target_os = "linux"))]
         libtest_mimic::Trial::test("wait_for_panic", move || {
             test::wait_for_panic();
             Ok(())
diff --git a/base/tests/unix/main.rs b/base/tests/unix/main.rs
index 745347e..6c346f9 100644
--- a/base/tests/unix/main.rs
+++ b/base/tests/unix/main.rs
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#![cfg(unix)]
+#![cfg(any(target_os = "android", target_os = "linux"))]
 
 use std::path::Path;
 
diff --git a/common/audio_streams/src/async_api.rs b/common/audio_streams/src/async_api.rs
index 51e97dd..038bec7 100644
--- a/common/audio_streams/src/async_api.rs
+++ b/common/audio_streams/src/async_api.rs
@@ -13,9 +13,9 @@
 //! The implementation is provided in `cros_async::audio_streams_async`.
 
 use std::io::Result;
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 use std::os::unix::io::RawFd as RawDescriptor;
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 use std::os::unix::net::UnixStream;
 #[cfg(windows)]
 use std::os::windows::io::RawHandle;
@@ -64,7 +64,7 @@
 #[async_trait(?Send)]
 pub trait AudioStreamsExecutor {
     /// Create an object to allow async reads/writes from the specified UnixStream.
-    #[cfg(unix)]
+    #[cfg(any(target_os = "android", target_os = "linux"))]
     fn async_unix_stream(&self, f: UnixStream) -> Result<AsyncStream>;
 
     /// Wraps an event that will be triggered when the audio backend is ready to read more audio
@@ -80,7 +80,7 @@
     async fn delay(&self, dur: Duration) -> Result<()>;
 
     // Returns a future that resolves after the provided descriptor is readable.
-    #[cfg(unix)]
+    #[cfg(any(target_os = "android", target_os = "linux"))]
     async fn wait_fd_readable(&self, _fd: RawDescriptor) -> Result<()> {
         Ok(())
     }
@@ -95,7 +95,7 @@
 
     #[async_trait(?Send)]
     impl AudioStreamsExecutor for TestExecutor {
-        #[cfg(unix)]
+        #[cfg(any(target_os = "android", target_os = "linux"))]
         fn async_unix_stream(&self, _f: UnixStream) -> Result<AsyncStream> {
             panic!("Not Implemented");
         }
@@ -110,7 +110,7 @@
             unimplemented!("async_event is not yet implemented on windows");
         }
 
-        #[cfg(unix)]
+        #[cfg(any(target_os = "android", target_os = "linux"))]
         async fn wait_fd_readable(&self, _fd: RawDescriptor) -> Result<()> {
             panic!("Not Implemented");
         }
diff --git a/common/audio_streams/src/audio_streams.rs b/common/audio_streams/src/audio_streams.rs
index e8dcaf2..f8b56f7 100644
--- a/common/audio_streams/src/audio_streams.rs
+++ b/common/audio_streams/src/audio_streams.rs
@@ -48,7 +48,7 @@
 use std::io;
 use std::io::Read;
 use std::io::Write;
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 use std::os::unix::io::RawFd as RawDescriptor;
 #[cfg(windows)]
 use std::os::windows::io::RawHandle as RawDescriptor;
diff --git a/common/audio_streams/src/shm_streams.rs b/common/audio_streams/src/shm_streams.rs
index c368f84..d0176fc 100644
--- a/common/audio_streams/src/shm_streams.rs
+++ b/common/audio_streams/src/shm_streams.rs
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 use std::os::unix::io::RawFd;
 use std::sync::Arc;
 use std::sync::Condvar;
@@ -174,7 +174,7 @@
     fn size(&self) -> u64;
 
     /// Returns the underlying raw fd.
-    #[cfg(unix)]
+    #[cfg(any(target_os = "android", target_os = "linux"))]
     fn as_raw_fd(&self) -> RawFd;
 }
 
@@ -224,7 +224,7 @@
     /// Returns any open file descriptors needed by the implementation.
     /// This list helps users of the ShmStreamSource enter Linux jails without
     /// closing needed file descriptors.
-    #[cfg(unix)]
+    #[cfg(any(target_os = "android", target_os = "linux"))]
     fn keep_fds(&self) -> Vec<RawFd> {
         Vec::new()
     }
@@ -500,7 +500,7 @@
             0
         }
 
-        #[cfg(unix)]
+        #[cfg(any(target_os = "android", target_os = "linux"))]
         fn as_raw_fd(&self) -> RawFd {
             0
         }
diff --git a/common/data_model/src/sys.rs b/common/data_model/src/sys.rs
index 97c6936..ccb7e2e 100644
--- a/common/data_model/src/sys.rs
+++ b/common/data_model/src/sys.rs
@@ -5,7 +5,7 @@
 //! A wrapper module for platform dependent code.
 
 cfg_if::cfg_if! {
-    if #[cfg(unix)] {
+    if #[cfg(any(target_os = "android", target_os = "linux"))] {
         mod unix;
         pub use unix::*;
     } else if #[cfg(windows)] {
diff --git a/cros_async/Cargo.toml b/cros_async/Cargo.toml
index f8c3842..3bbc882 100644
--- a/cros_async/Cargo.toml
+++ b/cros_async/Cargo.toml
@@ -24,7 +24,7 @@
 serde = "*"
 serde_keyvalue = { path = "../serde_keyvalue", features = ["argh_derive"] } # provided by ebuild
 
-[target.'cfg(unix)'.dependencies]
+[target.'cfg(any(target_os = "android", target_os = "linux"))'.dependencies]
 io_uring = { path = "../io_uring" } # provided by ebuild
 
 [target.'cfg(windows)'.dependencies]
diff --git a/cros_async/src/audio_streams_async.rs b/cros_async/src/audio_streams_async.rs
index f28e6de..894d4c6 100644
--- a/cros_async/src/audio_streams_async.rs
+++ b/cros_async/src/audio_streams_async.rs
@@ -7,30 +7,30 @@
 //! It implements the `AudioStreamsExecutor` trait for `Executor`, so it can be passed into
 //! the audio_streams API.
 use std::io::Result;
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 use std::os::unix::net::UnixStream;
 #[cfg(windows)]
 use std::os::windows::io::RawHandle;
 use std::time::Duration;
 
 use async_trait::async_trait;
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 use audio_streams::async_api::AsyncStream;
 use audio_streams::async_api::AudioStreamsExecutor;
 use audio_streams::async_api::EventAsyncWrapper;
 use audio_streams::async_api::ReadAsync;
 use audio_streams::async_api::ReadWriteAsync;
 use audio_streams::async_api::WriteAsync;
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 use base::Descriptor;
 #[cfg(windows)]
 use base::Event;
 #[cfg(windows)]
 use base::FromRawDescriptor;
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 use base::RawDescriptor;
 
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 use super::AsyncWrapper;
 use crate::EventAsync;
 use crate::IntoAsync;
@@ -82,7 +82,7 @@
 
 #[async_trait(?Send)]
 impl AudioStreamsExecutor for super::Executor {
-    #[cfg(unix)]
+    #[cfg(any(target_os = "android", target_os = "linux"))]
     fn async_unix_stream(&self, stream: UnixStream) -> Result<AsyncStream> {
         Ok(Box::new(IoSourceWrapper {
             source: self.async_from(AsyncWrapper::new(stream))?,
@@ -103,7 +103,7 @@
         TimerAsync::sleep(self, dur).await.map_err(Into::into)
     }
 
-    #[cfg(unix)]
+    #[cfg(any(target_os = "android", target_os = "linux"))]
     async fn wait_fd_readable(&self, fd: RawDescriptor) -> Result<()> {
         self.async_from(AsyncWrapper::new(Descriptor(fd)))?
             .wait_readable()
diff --git a/cros_async/src/blocking/sys.rs b/cros_async/src/blocking/sys.rs
index 1fddbbc..f80d48b 100644
--- a/cros_async/src/blocking/sys.rs
+++ b/cros_async/src/blocking/sys.rs
@@ -2,5 +2,5 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 pub mod unix;
diff --git a/cros_async/src/io_ext.rs b/cros_async/src/io_ext.rs
index ee0352d..c3481d8 100644
--- a/cros_async/src/io_ext.rs
+++ b/cros_async/src/io_ext.rs
@@ -9,12 +9,12 @@
 
 use base::AsRawDescriptor;
 use base::RawDescriptor;
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 use base::UnixSeqpacket;
 use remain::sorted;
 use thiserror::Error as ThisError;
 
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 #[sorted]
 #[derive(ThisError, Debug)]
 pub enum Error {
@@ -49,21 +49,21 @@
 
 pub type Result<T> = std::result::Result<T, Error>;
 
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 impl From<crate::sys::unix::uring_executor::Error> for Error {
     fn from(err: crate::sys::unix::uring_executor::Error) -> Self {
         Error::Uring(err)
     }
 }
 
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 impl From<crate::sys::unix::poll_source::Error> for Error {
     fn from(err: crate::sys::unix::poll_source::Error) -> Self {
         Error::Poll(err)
     }
 }
 
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 impl From<Error> for io::Error {
     fn from(e: Error) -> Self {
         use Error::*;
@@ -113,7 +113,7 @@
 pub trait IntoAsync: AsRawDescriptor {}
 
 impl IntoAsync for File {}
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 impl IntoAsync for UnixSeqpacket {}
 
 /// Simple wrapper struct to implement IntoAsync on foreign types.
diff --git a/cros_async/src/io_source.rs b/cros_async/src/io_source.rs
index f1fe7c2..f18a527 100644
--- a/cros_async/src/io_source.rs
+++ b/cros_async/src/io_source.rs
@@ -6,9 +6,9 @@
 
 use base::AsRawDescriptor;
 
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 use crate::sys::unix::PollSource;
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 use crate::sys::unix::UringSource;
 #[cfg(windows)]
 use crate::sys::windows::HandleSource;
@@ -21,9 +21,9 @@
 /// Associates an IO object `F` with cros_async's runtime and exposes an API to perform async IO on
 /// that object's descriptor.
 pub enum IoSource<F: base::AsRawDescriptor> {
-    #[cfg(unix)]
+    #[cfg(any(target_os = "android", target_os = "linux"))]
     Uring(UringSource<F>),
-    #[cfg(unix)]
+    #[cfg(any(target_os = "android", target_os = "linux"))]
     Epoll(PollSource<F>),
     #[cfg(windows)]
     Handle(HandleSource<F>),
@@ -32,14 +32,14 @@
 }
 
 pub enum AllocateMode {
-    #[cfg(unix)]
+    #[cfg(any(target_os = "android", target_os = "linux"))]
     Allocate,
     PunchHole,
     ZeroRange,
 }
 
 // This assume we always want KEEP_SIZE
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 impl From<AllocateMode> for u32 {
     fn from(value: AllocateMode) -> Self {
         match value {
@@ -60,9 +60,9 @@
 macro_rules! await_on_inner {
     ($x:ident, $method:ident $(, $args:expr)*) => {
         match $x {
-            #[cfg(unix)]
+            #[cfg(any(target_os = "android", target_os = "linux"))]
             IoSource::Uring(x) => UringSource::$method(x, $($args),*).await,
-            #[cfg(unix)]
+            #[cfg(any(target_os = "android", target_os = "linux"))]
             IoSource::Epoll(x) => PollSource::$method(x, $($args),*).await,
             #[cfg(windows)]
             IoSource::Handle(x) => HandleSource::$method(x, $($args),*).await,
@@ -78,9 +78,9 @@
 macro_rules! on_inner {
     ($x:ident, $method:ident $(, $args:expr)*) => {
         match $x {
-            #[cfg(unix)]
+            #[cfg(any(target_os = "android", target_os = "linux"))]
             IoSource::Uring(x) => UringSource::$method(x, $($args),*),
-            #[cfg(unix)]
+            #[cfg(any(target_os = "android", target_os = "linux"))]
             IoSource::Epoll(x) => PollSource::$method(x, $($args),*),
             #[cfg(windows)]
             IoSource::Handle(x) => HandleSource::$method(x, $($args),*),
@@ -192,13 +192,13 @@
 
     use super::*;
     use crate::mem::VecIoWrapper;
-    #[cfg(unix)]
+    #[cfg(any(target_os = "android", target_os = "linux"))]
     use crate::sys::unix::uring_executor::is_uring_stable;
     use crate::Executor;
     use crate::ExecutorKind;
     use crate::MemRegion;
 
-    #[cfg(unix)]
+    #[cfg(any(target_os = "android", target_os = "linux"))]
     fn all_kinds() -> Vec<ExecutorKind> {
         let mut kinds = vec![ExecutorKind::Fd];
         if is_uring_stable() {
diff --git a/cros_async/src/lib.rs b/cros_async/src/lib.rs
index a4396e0..10c48b8 100644
--- a/cros_async/src/lib.rs
+++ b/cros_async/src/lib.rs
@@ -66,7 +66,7 @@
 mod select;
 pub mod sync;
 pub mod sys;
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 pub use sys::unix::uring_executor::is_uring_stable;
 pub use sys::Executor;
 pub use sys::ExecutorKind;
@@ -81,7 +81,7 @@
 
 pub use async_types::*;
 pub use base::Event;
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 pub use blocking::sys::unix::block_on::block_on;
 pub use blocking::unblock;
 pub use blocking::unblock_disarm;
@@ -120,7 +120,7 @@
     #[error("IO error: {0}")]
     Io(std::io::Error),
     /// Error from the polled(FD) source, which includes error from the FD executor.
-    #[cfg(unix)]
+    #[cfg(any(target_os = "android", target_os = "linux"))]
     #[error("An error with a poll source: {0}")]
     PollSource(sys::unix::poll_source::Error),
     /// Error from Timer.
@@ -130,7 +130,7 @@
     #[error("Failure in TimerAsync: {0}")]
     TimerAsync(AsyncError),
     /// Error from the uring executor.
-    #[cfg(unix)]
+    #[cfg(any(target_os = "android", target_os = "linux"))]
     #[error("Failure in the uring executor: {0}")]
     URingExecutor(sys::unix::uring_executor::Error),
 }
diff --git a/cros_async/src/sync/cv.rs b/cros_async/src/sync/cv.rs
index 5fa9b18..77db210 100644
--- a/cros_async/src/sync/cv.rs
+++ b/cros_async/src/sync/cv.rs
@@ -452,7 +452,7 @@
 }
 
 // TODO(b/194338842): Fix tests for windows
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 #[cfg(test)]
 mod test {
     use std::future::Future;
diff --git a/cros_async/src/sync/mu.rs b/cros_async/src/sync/mu.rs
index 3173404..b3aa508 100644
--- a/cros_async/src/sync/mu.rs
+++ b/cros_async/src/sync/mu.rs
@@ -888,7 +888,7 @@
 }
 
 // TODO(b/194338842): Fix tests for windows
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 #[cfg(test)]
 mod test {
     use std::future::Future;
diff --git a/cros_async/src/sys.rs b/cros_async/src/sys.rs
index 7e613f5..88a6339 100644
--- a/cros_async/src/sys.rs
+++ b/cros_async/src/sys.rs
@@ -3,7 +3,7 @@
 // found in the LICENSE file.
 
 cfg_if::cfg_if! {
-    if #[cfg(unix)] {
+    if #[cfg(any(target_os = "android", target_os = "linux"))] {
         pub mod unix;
         pub use unix as platform;
     } else if #[cfg(windows)] {
diff --git a/cros_async/src/sys/unix/executor.rs b/cros_async/src/sys/unix/executor.rs
index 8fdfe7c..370d262 100644
--- a/cros_async/src/sys/unix/executor.rs
+++ b/cros_async/src/sys/unix/executor.rs
@@ -90,7 +90,7 @@
 ///     Ok(len)
 /// }
 ///
-/// #[cfg(unix)]
+/// #[cfg(any(target_os = "android", target_os = "linux"))]
 /// # fn do_it() -> Result<(), Box<dyn Error>> {
 ///     let ex = Executor::new()?;
 ///
@@ -119,7 +119,7 @@
 ///
 /// #     Ok(())
 /// # }
-/// #[cfg(unix)]
+/// #[cfg(any(target_os = "android", target_os = "linux"))]
 /// # do_it().unwrap();
 /// ```
 
diff --git a/cros_async/src/sys/unix/uring_source.rs b/cros_async/src/sys/unix/uring_source.rs
index 84b468a..9b675d9 100644
--- a/cros_async/src/sys/unix/uring_source.rs
+++ b/cros_async/src/sys/unix/uring_source.rs
@@ -399,7 +399,7 @@
         }
     }
 
-    #[cfg(unix)]
+    #[cfg(any(target_os = "android", target_os = "linux"))]
     #[test]
     fn await_uring_from_poll() {
         if !is_uring_stable() {
@@ -434,7 +434,7 @@
         handle.join().unwrap().unwrap();
     }
 
-    #[cfg(unix)]
+    #[cfg(any(target_os = "android", target_os = "linux"))]
     #[test]
     fn await_poll_from_uring() {
         if !is_uring_stable() {
diff --git a/cros_async/src/sys/windows/executor.rs b/cros_async/src/sys/windows/executor.rs
index d5c5bcb..06528d3 100644
--- a/cros_async/src/sys/windows/executor.rs
+++ b/cros_async/src/sys/windows/executor.rs
@@ -82,7 +82,7 @@
 ///     Ok(len)
 /// }
 ///
-/// #[cfg(unix)]
+/// #[cfg(any(target_os = "android", target_os = "linux"))]
 /// # fn do_it() -> Result<(), Box<dyn Error>> {
 ///     let ex = Executor::new()?;
 ///
@@ -111,7 +111,7 @@
 ///
 /// #     Ok(())
 /// # }
-/// #[cfg(unix)]
+/// #[cfg(any(target_os = "android", target_os = "linux"))]
 /// # do_it().unwrap();
 /// ```
 
diff --git a/cros_async/tests/executor.rs b/cros_async/tests/executor.rs
index c2ac572..6f14f16 100644
--- a/cros_async/tests/executor.rs
+++ b/cros_async/tests/executor.rs
@@ -5,7 +5,7 @@
 use cros_async::Executor;
 use cros_async::ExecutorKind;
 
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 fn all_kinds() -> Vec<ExecutorKind> {
     let mut kinds = vec![ExecutorKind::Fd];
     if cros_async::is_uring_stable() {
diff --git a/crosvm_control/src/lib.rs b/crosvm_control/src/lib.rs
index 1861473..e8672f7 100644
--- a/crosvm_control/src/lib.rs
+++ b/crosvm_control/src/lib.rs
@@ -19,7 +19,7 @@
 use std::panic::catch_unwind;
 use std::path::Path;
 use std::path::PathBuf;
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 use std::time::Duration;
 
 use libc::c_char;
@@ -166,7 +166,7 @@
 }
 
 /// See crosvm_client_balloon_vms.
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 #[no_mangle]
 pub unsafe extern "C" fn crosvm_client_balloon_vms_wait_with_timeout(
     socket_path: *const c_char,
@@ -702,7 +702,7 @@
 ) -> bool {
     crosvm_client_balloon_stats_impl(
         socket_path,
-        #[cfg(unix)]
+        #[cfg(any(target_os = "android", target_os = "linux"))]
         None,
         stats,
         actual,
@@ -710,7 +710,7 @@
 }
 
 /// See crosvm_client_balloon_stats.
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 #[no_mangle]
 pub unsafe extern "C" fn crosvm_client_balloon_stats_with_timeout(
     socket_path: *const c_char,
@@ -728,7 +728,7 @@
 
 fn crosvm_client_balloon_stats_impl(
     socket_path: *const c_char,
-    #[cfg(unix)] timeout_ms: Option<Duration>,
+    #[cfg(any(target_os = "android", target_os = "linux"))] timeout_ms: Option<Duration>,
     stats: *mut BalloonStatsFfi,
     actual: *mut u64,
 ) -> bool {
@@ -737,7 +737,7 @@
             let request = &VmRequest::BalloonCommand(BalloonControlCommand::Stats {});
             #[cfg(not(unix))]
             let resp = handle_request(request, socket_path);
-            #[cfg(unix)]
+            #[cfg(any(target_os = "android", target_os = "linux"))]
             let resp = handle_request_with_timeout(request, socket_path, timeout_ms);
             if let Ok(VmResponse::BalloonStats {
                 stats: ref balloon_stats,
diff --git a/crosvm_plugin/src/lib.rs b/crosvm_plugin/src/lib.rs
index 76ff561..84a0430 100644
--- a/crosvm_plugin/src/lib.rs
+++ b/crosvm_plugin/src/lib.rs
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#![cfg(unix)]
+#![cfg(any(target_os = "android", target_os = "linux"))]
 #![cfg(target_arch = "x86_64")]
 #![allow(non_camel_case_types)]
 
diff --git a/devices/Cargo.toml b/devices/Cargo.toml
index ecf9603..0207dee 100644
--- a/devices/Cargo.toml
+++ b/devices/Cargo.toml
@@ -88,7 +88,7 @@
 vm_memory = { path = "../vm_memory" }
 zerocopy = { version = "0.7", features = ["derive"] }
 
-[target.'cfg(unix)'.dependencies]
+[target.'cfg(any(target_os = "android", target_os = "linux"))'.dependencies]
 fuse = {path = "../fuse" }
 libcras = { version = "*", optional = true }
 minijail = "*"
diff --git a/devices/src/bus.rs b/devices/src/bus.rs
index 6387999..c7eb3ee 100644
--- a/devices/src/bus.rs
+++ b/devices/src/bus.rs
@@ -33,7 +33,7 @@
 use crate::PciAddress;
 use crate::PciDevice;
 use crate::Suspendable;
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 use crate::VfioPlatformDevice;
 use crate::VirtioMmioDevice;
 
@@ -231,15 +231,15 @@
     fn into_pci_device(self: Box<Self>) -> Option<Box<dyn PciDevice>> {
         None
     }
-    #[cfg(unix)]
+    #[cfg(any(target_os = "android", target_os = "linux"))]
     fn as_platform_device(&self) -> Option<&VfioPlatformDevice> {
         None
     }
-    #[cfg(unix)]
+    #[cfg(any(target_os = "android", target_os = "linux"))]
     fn as_platform_device_mut(&mut self) -> Option<&mut VfioPlatformDevice> {
         None
     }
-    #[cfg(unix)]
+    #[cfg(any(target_os = "android", target_os = "linux"))]
     fn into_platform_device(self: Box<Self>) -> Option<Box<VfioPlatformDevice>> {
         None
     }
diff --git a/devices/src/irqchip/mod.rs b/devices/src/irqchip/mod.rs
index 8c8cee9..512607d 100644
--- a/devices/src/irqchip/mod.rs
+++ b/devices/src/irqchip/mod.rs
@@ -22,7 +22,7 @@
 use crate::IrqLevelEvent;
 
 cfg_if::cfg_if! {
-    if #[cfg(unix)] {
+    if #[cfg(any(target_os = "android", target_os = "linux"))] {
         mod kvm;
         pub use self::kvm::KvmKernelIrqChip;
         #[cfg(target_arch = "x86_64")]
diff --git a/devices/src/lib.rs b/devices/src/lib.rs
index c0ffba7..91150ce 100644
--- a/devices/src/lib.rs
+++ b/devices/src/lib.rs
@@ -134,7 +134,7 @@
 pub use self::vtpm_proxy::VtpmProxy;
 
 cfg_if::cfg_if! {
-    if #[cfg(unix)] {
+    if #[cfg(any(target_os = "android", target_os = "linux"))] {
         mod platform;
         mod proxy;
         pub mod vmwdt;
diff --git a/devices/src/pci/mod.rs b/devices/src/pci/mod.rs
index e0e79d6..53a7c4c 100644
--- a/devices/src/pci/mod.rs
+++ b/devices/src/pci/mod.rs
@@ -5,7 +5,7 @@
 //! Implements pci devices and busses.
 
 mod acpi;
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 mod coiommu;
 mod msi;
 mod msix;
@@ -15,12 +15,12 @@
 #[cfg(feature = "pci-hotplug")]
 mod pci_hotplug;
 mod pci_root;
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 mod pcie;
 mod pm;
 mod pvpanic;
 mod stub;
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 mod vfio_pci;
 
 use libc::EINVAL;
@@ -31,11 +31,11 @@
 pub use self::acpi::DsmMethod;
 pub use self::acpi::GpeScope;
 pub use self::acpi::PowerResourceMethod;
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 pub use self::coiommu::CoIommuDev;
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 pub use self::coiommu::CoIommuParameters;
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 pub use self::coiommu::CoIommuUnpinPolicy;
 pub use self::msi::MsiConfig;
 pub use self::msix::MsixCap;
@@ -77,21 +77,21 @@
 pub use self::pci_root::PciRoot;
 pub use self::pci_root::PciRootCommand;
 pub use self::pci_root::PciVirtualConfigMmio;
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 pub use self::pcie::PciBridge;
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 pub use self::pcie::PcieDownstreamPort;
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 pub use self::pcie::PcieHostPort;
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 pub use self::pcie::PcieRootPort;
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 pub use self::pcie::PcieUpstreamPort;
 pub use self::pvpanic::PvPanicCode;
 pub use self::pvpanic::PvPanicPciDevice;
 pub use self::stub::StubPciDevice;
 pub use self::stub::StubPciParameters;
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 pub use self::vfio_pci::VfioPciDevice;
 
 /// PCI has four interrupt pins A->D.
diff --git a/devices/src/pci/pci_configuration.rs b/devices/src/pci/pci_configuration.rs
index a9d3eb2..2f15d61 100644
--- a/devices/src/pci/pci_configuration.rs
+++ b/devices/src/pci/pci_configuration.rs
@@ -26,7 +26,7 @@
 const STATUS_REG: usize = 1;
 pub const STATUS_REG_CAPABILITIES_USED_MASK: u32 = 0x0010_0000;
 #[allow(dead_code)]
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 pub const CLASS_REG: usize = 2;
 pub const HEADER_TYPE_REG: usize = 3;
 pub const HEADER_TYPE_MULTIFUNCTION_MASK: u32 = 0x0080_0000;
@@ -40,7 +40,7 @@
 pub const ROM_BAR_IDX: PciBarIndex = 6;
 pub const ROM_BAR_REG: usize = 12;
 pub const CAPABILITY_LIST_HEAD_OFFSET: usize = 0x34;
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 pub const PCI_CAP_NEXT_POINTER: usize = 0x1;
 const FIRST_CAPABILITY_OFFSET: usize = 0x40;
 pub const CAPABILITY_MAX_OFFSET: usize = 255;
diff --git a/devices/src/serial/sys.rs b/devices/src/serial/sys.rs
index 3a64390..26ba426 100644
--- a/devices/src/serial/sys.rs
+++ b/devices/src/serial/sys.rs
@@ -3,7 +3,7 @@
 // found in the LICENSE file.
 
 cfg_if::cfg_if! {
-    if #[cfg(unix)] {
+    if #[cfg(any(target_os = "android", target_os = "linux"))] {
         pub(in crate::serial) mod unix;
         use unix as platform;
     } else if #[cfg(windows)] {
diff --git a/devices/src/serial_device.rs b/devices/src/serial_device.rs
index 055fe78..56b951c 100644
--- a/devices/src/serial_device.rs
+++ b/devices/src/serial_device.rs
@@ -280,7 +280,7 @@
         assert_eq!(params.type_, SerialType::Sink);
         let params = from_serial_arg("type=syslog").unwrap();
         assert_eq!(params.type_, SerialType::Syslog);
-        #[cfg(unix)]
+        #[cfg(any(target_os = "android", target_os = "linux"))]
         let opt = "type=unix";
         #[cfg(windows)]
         let opt = "type=namedpipe";
diff --git a/devices/src/sys.rs b/devices/src/sys.rs
index ad84dd9..d873b05 100644
--- a/devices/src/sys.rs
+++ b/devices/src/sys.rs
@@ -3,7 +3,7 @@
 // found in the LICENSE file.
 
 cfg_if::cfg_if! {
-    if #[cfg(unix)] {
+    if #[cfg(any(target_os = "android", target_os = "linux"))] {
         pub(crate) mod unix;
         use unix as platform;
         pub(crate) use unix::*;
diff --git a/devices/src/virtio/balloon.rs b/devices/src/virtio/balloon.rs
index c7698ff..a3cd0f9 100644
--- a/devices/src/virtio/balloon.rs
+++ b/devices/src/virtio/balloon.rs
@@ -981,7 +981,7 @@
                     len,
                     #[cfg(windows)]
                     &vm_memory_client,
-                    #[cfg(unix)]
+                    #[cfg(any(target_os = "android", target_os = "linux"))]
                     &mem,
                 )
             },
@@ -1060,7 +1060,7 @@
                         len,
                         #[cfg(windows)]
                         &vm_memory_client,
-                        #[cfg(unix)]
+                        #[cfg(any(target_os = "android", target_os = "linux"))]
                         &mem,
                     )
                 },
diff --git a/devices/src/virtio/balloon/sys.rs b/devices/src/virtio/balloon/sys.rs
index 1d0bcb9..28bf341 100644
--- a/devices/src/virtio/balloon/sys.rs
+++ b/devices/src/virtio/balloon/sys.rs
@@ -3,7 +3,7 @@
 // found in the LICENSE file.
 
 cfg_if::cfg_if! {
-    if #[cfg(unix)] {
+    if #[cfg(any(target_os = "android", target_os = "linux"))] {
         mod unix;
         use unix as platform;
     } else if #[cfg(windows)] {
diff --git a/devices/src/virtio/block/asynchronous.rs b/devices/src/virtio/block/asynchronous.rs
index 5228b37..ceb4506 100644
--- a/devices/src/virtio/block/asynchronous.rs
+++ b/devices/src/virtio/block/asynchronous.rs
@@ -1549,20 +1549,20 @@
     }
 
     // TODO(b/270225199): enable this test on Windows once IoSource::into_source is implemented
-    #[cfg(unix)]
+    #[cfg(any(target_os = "android", target_os = "linux"))]
     #[test]
     fn reset_and_reactivate_single_worker() {
         reset_and_reactivate(false);
     }
 
     // TODO(b/270225199): enable this test on Windows once IoSource::into_source is implemented
-    #[cfg(unix)]
+    #[cfg(any(target_os = "android", target_os = "linux"))]
     #[test]
     fn reset_and_reactivate_multiple_workers() {
         reset_and_reactivate(true);
     }
 
-    #[cfg(unix)]
+    #[cfg(any(target_os = "android", target_os = "linux"))]
     fn reset_and_reactivate(enables_multiple_workers: bool) {
         // Create an empty disk image
         let f = tempfile().unwrap();
@@ -1662,7 +1662,7 @@
 
     // TODO(b/270225199): enable this test on Windows once IoSource::into_source is implemented,
     // or after finding a good way to prevent BlockAsync::drop() from panicking due to that.
-    #[cfg(unix)]
+    #[cfg(any(target_os = "android", target_os = "linux"))]
     #[test]
     fn resize_with_single_worker() {
         resize(false);
@@ -1670,7 +1670,7 @@
 
     // TODO(b/270225199): enable this test on Windows once IoSource::into_source is implemented,
     // or after finding a good way to prevent BlockAsync::drop() from panicking due to that.
-    #[cfg(unix)]
+    #[cfg(any(target_os = "android", target_os = "linux"))]
     #[test]
     fn resize_with_multiple_workers() {
         // Test resize handled by one worker affect the whole state
@@ -1789,7 +1789,7 @@
 
     // TODO(b/270225199): enable this test on Windows once IoSource::into_source is implemented,
     // or after finding a good way to prevent BlockAsync::drop() from panicking due to that.
-    #[cfg(unix)]
+    #[cfg(any(target_os = "android", target_os = "linux"))]
     #[test]
     fn run_worker_threads() {
         // Create an empty duplicable disk image
@@ -1906,6 +1906,6 @@
         )
     }
 
-    #[cfg(unix)]
+    #[cfg(any(target_os = "android", target_os = "linux"))]
     suspendable_virtio_tests!(asyncblock, create_device, 2, modify_device);
 }
diff --git a/devices/src/virtio/block/mod.rs b/devices/src/virtio/block/mod.rs
index 9d3f0f3..659d4a0 100644
--- a/devices/src/virtio/block/mod.rs
+++ b/devices/src/virtio/block/mod.rs
@@ -464,7 +464,7 @@
         // async-executor
         #[cfg(windows)]
         let (ex_kind, ex_kind_opt) = (ExecutorKind::Handle, "handle");
-        #[cfg(unix)]
+        #[cfg(any(target_os = "android", target_os = "linux"))]
         let (ex_kind, ex_kind_opt) = (ExecutorKind::Fd, "epoll");
         let params =
             from_block_arg(&format!("/some/path.img,async-executor={ex_kind_opt}")).unwrap();
diff --git a/devices/src/virtio/block/sys/mod.rs b/devices/src/virtio/block/sys/mod.rs
index b2e99b6..5e5c88d 100644
--- a/devices/src/virtio/block/sys/mod.rs
+++ b/devices/src/virtio/block/sys/mod.rs
@@ -3,7 +3,7 @@
 // found in the LICENSE file.
 
 cfg_if::cfg_if! {
-    if #[cfg(unix)] {
+    if #[cfg(any(target_os = "android", target_os = "linux"))] {
         mod unix;
         pub use self::unix::*;
     } else if #[cfg(windows)] {
diff --git a/devices/src/virtio/console.rs b/devices/src/virtio/console.rs
index 8496c44..90d318e 100644
--- a/devices/src/virtio/console.rs
+++ b/devices/src/virtio/console.rs
@@ -5,7 +5,7 @@
 //! Legacy console device that uses a polling thread. This is kept because it is still used by
 //! Windows ; outside of this use-case, please use [[asynchronous::AsyncConsole]] instead.
 
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 pub mod asynchronous;
 mod sys;
 
diff --git a/devices/src/virtio/console/sys.rs b/devices/src/virtio/console/sys.rs
index cf0d6ea..9c9c284 100644
--- a/devices/src/virtio/console/sys.rs
+++ b/devices/src/virtio/console/sys.rs
@@ -3,7 +3,7 @@
 // found in the LICENSE file.
 
 cfg_if::cfg_if! {
-    if #[cfg(unix)] {
+    if #[cfg(any(target_os = "android", target_os = "linux"))] {
         mod unix;
         use unix as platform;
     } else if #[cfg(windows)] {
diff --git a/devices/src/virtio/gpu/mod.rs b/devices/src/virtio/gpu/mod.rs
index 1ecd088..72046f3 100644
--- a/devices/src/virtio/gpu/mod.rs
+++ b/devices/src/virtio/gpu/mod.rs
@@ -21,7 +21,7 @@
 use anyhow::Context;
 use base::debug;
 use base::error;
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 use base::platform::move_task_to_cgroup;
 use base::warn;
 use base::AsRawDescriptor;
@@ -800,7 +800,7 @@
     CtrlQueue,
     CursorQueue,
     Display,
-    #[cfg(unix)]
+    #[cfg(any(target_os = "android", target_os = "linux"))]
     GpuControl,
     InterruptResample,
     Kill,
@@ -857,7 +857,7 @@
 struct Worker {
     interrupt: Interrupt,
     exit_evt_wrtube: SendTube,
-    #[cfg(unix)]
+    #[cfg(any(target_os = "android", target_os = "linux"))]
     gpu_control_tube: Tube,
     mem: GuestMemory,
     ctrl_queue: SharedQueueReader,
@@ -870,7 +870,7 @@
 }
 
 struct WorkerReturn {
-    #[cfg(unix)]
+    #[cfg(any(target_os = "android", target_os = "linux"))]
     gpu_control_tube: Tube,
     resource_bridges: ResourceBridges,
     event_devices: Vec<EventDevice>,
@@ -915,7 +915,7 @@
             (&ctrl_evt, WorkerToken::CtrlQueue),
             (&cursor_evt, WorkerToken::CursorQueue),
             (&display_desc, WorkerToken::Display),
-            #[cfg(unix)]
+            #[cfg(any(target_os = "android", target_os = "linux"))]
             (&self.gpu_control_tube, WorkerToken::GpuControl),
             (&self.kill_evt, WorkerToken::Kill),
             #[cfg(windows)]
@@ -1027,7 +1027,7 @@
                             error!("failed to receive ModifyWaitContext request.")
                         }
                     }
-                    #[cfg(unix)]
+                    #[cfg(any(target_os = "android", target_os = "linux"))]
                     WorkerToken::GpuControl => {
                         let req = match self.gpu_control_tube.recv() {
                             Ok(req) => req,
@@ -1110,10 +1110,10 @@
 /// to use as fallbacks in case some do not work.
 #[derive(Clone)]
 pub enum DisplayBackend {
-    #[cfg(unix)]
+    #[cfg(any(target_os = "android", target_os = "linux"))]
     /// Use the wayland backend with the given socket path if given.
     Wayland(Option<PathBuf>),
-    #[cfg(unix)]
+    #[cfg(any(target_os = "android", target_os = "linux"))]
     /// Open a connection to the X server at the given display if given.
     X(Option<String>),
     /// Emulate a display without actually displaying it.
@@ -1130,9 +1130,9 @@
         #[cfg(windows)] gpu_display_wait_descriptor_ctrl: SendTube,
     ) -> std::result::Result<GpuDisplay, GpuDisplayError> {
         match self {
-            #[cfg(unix)]
+            #[cfg(any(target_os = "android", target_os = "linux"))]
             DisplayBackend::Wayland(path) => GpuDisplay::open_wayland(path.as_ref()),
-            #[cfg(unix)]
+            #[cfg(any(target_os = "android", target_os = "linux"))]
             DisplayBackend::X(display) => GpuDisplay::open_x(display.as_deref()),
             DisplayBackend::Stub => GpuDisplay::open_stub(),
             #[cfg(windows)]
@@ -1163,7 +1163,7 @@
 
 pub struct Gpu {
     exit_evt_wrtube: SendTube,
-    #[cfg(unix)]
+    #[cfg(any(target_os = "android", target_os = "linux"))]
     gpu_control_tube: Option<Tube>,
     mapper: Arc<Mutex<Option<Box<dyn SharedMemoryMapper>>>>,
     resource_bridges: Option<ResourceBridges>,
@@ -1199,7 +1199,7 @@
     /// context.
     gpu_display_wait_descriptor_ctrl_rd: Option<RecvTube>,
     capset_mask: u64,
-    #[cfg(unix)]
+    #[cfg(any(target_os = "android", target_os = "linux"))]
     gpu_cgroup_path: Option<PathBuf>,
     /// Used to differentiate worker kill events that are for shutdown vs sleep. `virtio_sleep`
     /// sets this to true while stopping the worker.
@@ -1210,7 +1210,7 @@
 impl Gpu {
     pub fn new(
         exit_evt_wrtube: SendTube,
-        #[cfg(unix)] gpu_control_tube: Tube,
+        #[cfg(any(target_os = "android", target_os = "linux"))] gpu_control_tube: Tube,
         resource_bridges: Vec<Tube>,
         display_backends: Vec<DisplayBackend>,
         gpu_parameters: &GpuParameters,
@@ -1219,7 +1219,7 @@
         base_features: u64,
         channels: &BTreeMap<String, PathBuf>,
         #[cfg(windows)] wndproc_thread: WindowProcedureThread,
-        #[cfg(unix)] gpu_cgroup_path: Option<&PathBuf>,
+        #[cfg(any(target_os = "android", target_os = "linux"))] gpu_cgroup_path: Option<&PathBuf>,
     ) -> Gpu {
         let mut display_params = gpu_parameters.display_params.clone();
         if display_params.is_empty() {
@@ -1282,7 +1282,7 @@
 
         Gpu {
             exit_evt_wrtube,
-            #[cfg(unix)]
+            #[cfg(any(target_os = "android", target_os = "linux"))]
             gpu_control_tube: Some(gpu_control_tube),
             mapper: Arc::new(Mutex::new(None)),
             resource_bridges: Some(ResourceBridges::new(resource_bridges)),
@@ -1306,7 +1306,7 @@
             #[cfg(windows)]
             gpu_display_wait_descriptor_ctrl_rd: Some(gpu_display_wait_descriptor_ctrl_rd),
             capset_mask: gpu_parameters.capset_mask,
-            #[cfg(unix)]
+            #[cfg(any(target_os = "android", target_os = "linux"))]
             gpu_cgroup_path: gpu_cgroup_path.cloned(),
             sleep_requested: Arc::new(AtomicBool::new(false)),
             worker_snapshot: None,
@@ -1366,7 +1366,7 @@
             .context("error cloning exit tube")
             .unwrap();
 
-        #[cfg(unix)]
+        #[cfg(any(target_os = "android", target_os = "linux"))]
         let gpu_control_tube = self
             .gpu_control_tube
             .take()
@@ -1402,7 +1402,7 @@
             .take()
             .expect("failed to take gpu_display_wait_descriptor_ctrl_rd");
 
-        #[cfg(unix)]
+        #[cfg(any(target_os = "android", target_os = "linux"))]
         let gpu_cgroup_path = self.gpu_cgroup_path.clone();
 
         let mapper = Arc::clone(&self.mapper);
@@ -1417,7 +1417,7 @@
         let sleep_requested = self.sleep_requested.clone();
 
         let worker_thread = WorkerThread::start("v_gpu", move |kill_evt| {
-            #[cfg(unix)]
+            #[cfg(any(target_os = "android", target_os = "linux"))]
             if let Some(cgroup_path) = gpu_cgroup_path {
                 move_task_to_cgroup(cgroup_path, base::gettid())
                     .expect("Failed to move v_gpu into requested cgroup");
@@ -1434,7 +1434,7 @@
                     Err(e) => {
                         error!("failed to build rutabaga {}", e);
                         return WorkerReturn {
-                            #[cfg(unix)]
+                            #[cfg(any(target_os = "android", target_os = "linux"))]
                             gpu_control_tube,
                             resource_bridges,
                             event_devices,
@@ -1459,7 +1459,7 @@
                 Some(backend) => backend,
                 None => {
                     return WorkerReturn {
-                        #[cfg(unix)]
+                        #[cfg(any(target_os = "android", target_os = "linux"))]
                         gpu_control_tube,
                         resource_bridges,
                         event_devices,
@@ -1483,7 +1483,7 @@
                 // Other half of channel was dropped.
                 Err(mpsc::RecvError) => {
                     return WorkerReturn {
-                        #[cfg(unix)]
+                        #[cfg(any(target_os = "android", target_os = "linux"))]
                         gpu_control_tube,
                         resource_bridges,
                         event_devices: virtio_gpu.display().borrow_mut().take_event_devices(),
@@ -1504,7 +1504,7 @@
             let mut worker = Worker {
                 interrupt: activation_resources.interrupt,
                 exit_evt_wrtube,
-                #[cfg(unix)]
+                #[cfg(any(target_os = "android", target_os = "linux"))]
                 gpu_control_tube,
                 mem: activation_resources.mem,
                 ctrl_queue: activation_resources.ctrl_queue,
@@ -1565,7 +1565,7 @@
                 None
             };
             WorkerReturn {
-                #[cfg(unix)]
+                #[cfg(any(target_os = "android", target_os = "linux"))]
                 gpu_control_tube: worker.gpu_control_tube,
                 resource_bridges: worker.resource_bridges,
                 event_devices,
@@ -1640,7 +1640,7 @@
         // casting the underlying DMA buffer wrapped in File to a copyable RawDescriptor.
         // TODO(davidriley): Remove once virgl has another path to include
         // debugging logs.
-        #[cfg(unix)]
+        #[cfg(any(target_os = "android", target_os = "linux"))]
         if cfg!(debug_assertions) {
             keep_rds.push(libc::STDOUT_FILENO);
             keep_rds.push(libc::STDERR_FILENO);
@@ -1658,7 +1658,7 @@
 
         keep_rds.push(self.exit_evt_wrtube.as_raw_descriptor());
 
-        #[cfg(unix)]
+        #[cfg(any(target_os = "android", target_os = "linux"))]
         if let Some(gpu_control_tube) = &self.gpu_control_tube {
             keep_rds.push(gpu_control_tube.as_raw_descriptor());
         }
@@ -1802,7 +1802,7 @@
             self.sleep_requested.store(true, Ordering::SeqCst);
             drop(activate_tx);
             let WorkerReturn {
-                #[cfg(unix)]
+                #[cfg(any(target_os = "android", target_os = "linux"))]
                 gpu_control_tube,
                 resource_bridges,
                 event_devices,
@@ -1811,7 +1811,7 @@
             self.sleep_requested.store(false, Ordering::SeqCst);
 
             self.resource_bridges = Some(resource_bridges);
-            #[cfg(unix)]
+            #[cfg(any(target_os = "android", target_os = "linux"))]
             {
                 self.gpu_control_tube = Some(gpu_control_tube);
             }
diff --git a/devices/src/virtio/iommu/sys.rs b/devices/src/virtio/iommu/sys.rs
index 4da523e..0439bce 100644
--- a/devices/src/virtio/iommu/sys.rs
+++ b/devices/src/virtio/iommu/sys.rs
@@ -3,7 +3,7 @@
 // found in the LICENSE file.
 
 cfg_if::cfg_if! {
-    if #[cfg(unix)] {
+    if #[cfg(any(target_os = "android", target_os = "linux"))] {
         pub mod unix;
         use unix as platform;
     } else if #[cfg(windows)] {
diff --git a/devices/src/virtio/mod.rs b/devices/src/virtio/mod.rs
index 63ae054..892e82c 100644
--- a/devices/src/virtio/mod.rs
+++ b/devices/src/virtio/mod.rs
@@ -105,7 +105,7 @@
 pub use self::virtio_pci_device::VirtioPciShmCap;
 
 cfg_if::cfg_if! {
-    if #[cfg(unix)] {
+    if #[cfg(any(target_os = "android", target_os = "linux"))] {
         mod p9;
         mod pmem;
 
diff --git a/devices/src/virtio/net.rs b/devices/src/virtio/net.rs
index c138519..99763d9 100644
--- a/devices/src/virtio/net.rs
+++ b/devices/src/virtio/net.rs
@@ -64,7 +64,7 @@
 pub(crate) const MAX_BUFFER_SIZE: usize = 65562;
 const QUEUE_SIZE: u16 = 256;
 
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 pub static VHOST_NET_DEFAULT_PATH: &str = "/dev/vhost-net";
 
 pub(crate) use sys::process_rx;
@@ -98,7 +98,7 @@
     #[error("failed to read control message header: {0}")]
     ReadCtrlHeader(io::Error),
     /// There are no more available descriptors to receive into.
-    #[cfg(unix)]
+    #[cfg(any(target_os = "android", target_os = "linux"))]
     #[error("no rx descriptors available")]
     RxDescriptorsExhausted,
     /// Failure creating the Slirp loop.
@@ -145,7 +145,7 @@
     #[error("failed to write control message ack: {0}")]
     WriteAck(io::Error),
     /// Writing to a buffer in the guest failed.
-    #[cfg(unix)]
+    #[cfg(any(target_os = "android", target_os = "linux"))]
     #[error("failed to write to guest buffer: {0}")]
     WriteBuffer(io::Error),
 }
@@ -171,12 +171,12 @@
     },
 }
 
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 fn vhost_net_device_path_default() -> PathBuf {
     PathBuf::from(VHOST_NET_DEFAULT_PATH)
 }
 
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]
 #[serde(rename_all = "kebab-case", deny_unknown_fields)]
 pub struct VhostNetParameters {
@@ -184,7 +184,7 @@
     pub device: PathBuf,
 }
 
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 impl Default for VhostNetParameters {
     fn default() -> Self {
         Self {
@@ -201,7 +201,7 @@
     pub vq_pairs: Option<u16>,
     // Style-guide asks to refrain against #[cfg] directives in structs, this is an exception due
     // to the fact this struct is used for argument parsing.
-    #[cfg(unix)]
+    #[cfg(any(target_os = "android", target_os = "linux"))]
     pub vhost_net: Option<VhostNetParameters>,
     #[serde(default)]
     pub packed_queue: bool,
@@ -401,7 +401,7 @@
                 self.overlapped_wrapper.get_h_event_ref().unwrap(),
                 Token::RxTap,
             ),
-            #[cfg(unix)]
+            #[cfg(any(target_os = "android", target_os = "linux"))]
             (self.tap.get_read_notifier(), Token::RxTap),
             (self.rx_queue.event(), Token::RxQueue),
             (self.tx_queue.event(), Token::TxQueue),
@@ -906,7 +906,7 @@
         assert_eq!(
             params,
             NetParameters {
-                #[cfg(unix)]
+                #[cfg(any(target_os = "android", target_os = "linux"))]
                 vhost_net: None,
                 vq_pairs: None,
                 mode: NetParametersMode::TapName {
@@ -921,7 +921,7 @@
         assert_eq!(
             params,
             NetParameters {
-                #[cfg(unix)]
+                #[cfg(any(target_os = "android", target_os = "linux"))]
                 vhost_net: None,
                 vq_pairs: None,
                 mode: NetParametersMode::TapName {
@@ -936,7 +936,7 @@
         assert_eq!(
             params,
             NetParameters {
-                #[cfg(unix)]
+                #[cfg(any(target_os = "android", target_os = "linux"))]
                 vhost_net: None,
                 vq_pairs: None,
                 mode: NetParametersMode::TapFd {
@@ -951,7 +951,7 @@
         assert_eq!(
             params,
             NetParameters {
-                #[cfg(unix)]
+                #[cfg(any(target_os = "android", target_os = "linux"))]
                 vhost_net: None,
                 vq_pairs: None,
                 mode: NetParametersMode::TapFd {
@@ -969,7 +969,7 @@
         assert_eq!(
             params,
             NetParameters {
-                #[cfg(unix)]
+                #[cfg(any(target_os = "android", target_os = "linux"))]
                 vhost_net: None,
                 vq_pairs: None,
                 mode: NetParametersMode::RawConfig {
@@ -989,7 +989,7 @@
     }
 
     #[test]
-    #[cfg(unix)]
+    #[cfg(any(target_os = "android", target_os = "linux"))]
     fn params_from_key_values_vhost_net() {
         let params = from_net_arg(
             "vhost-net=[device=/dev/foo],\
@@ -1061,7 +1061,7 @@
         assert_eq!(
             params,
             NetParameters {
-                #[cfg(unix)]
+                #[cfg(any(target_os = "android", target_os = "linux"))]
                 vhost_net: None,
                 vq_pairs: None,
                 mode: NetParametersMode::TapName {
@@ -1076,7 +1076,7 @@
         assert_eq!(
             params,
             NetParameters {
-                #[cfg(unix)]
+                #[cfg(any(target_os = "android", target_os = "linux"))]
                 vhost_net: None,
                 vq_pairs: None,
                 mode: NetParametersMode::TapName {
diff --git a/devices/src/virtio/net/sys.rs b/devices/src/virtio/net/sys.rs
index 1cdd720..d2670a5 100644
--- a/devices/src/virtio/net/sys.rs
+++ b/devices/src/virtio/net/sys.rs
@@ -3,7 +3,7 @@
 // found in the LICENSE file.
 
 cfg_if::cfg_if! {
-    if #[cfg(unix)] {
+    if #[cfg(any(target_os = "android", target_os = "linux"))] {
         mod unix;
         use unix as platform;
     } else if #[cfg(windows)] {
diff --git a/devices/src/virtio/scsi/sys/mod.rs b/devices/src/virtio/scsi/sys/mod.rs
index fab3371..bf716be 100644
--- a/devices/src/virtio/scsi/sys/mod.rs
+++ b/devices/src/virtio/scsi/sys/mod.rs
@@ -3,7 +3,7 @@
 // found in the LICENSE file.
 
 cfg_if::cfg_if! {
-    if #[cfg(unix)] {
+    if #[cfg(any(target_os = "android", target_os = "linux"))] {
         mod unix;
     } else if #[cfg(windows)] {
         mod windows;
diff --git a/devices/src/virtio/snd/common_backend/async_funcs.rs b/devices/src/virtio/snd/common_backend/async_funcs.rs
index 45deb57..3f8b453 100644
--- a/devices/src/virtio/snd/common_backend/async_funcs.rs
+++ b/devices/src/virtio/snd/common_backend/async_funcs.rs
@@ -376,7 +376,7 @@
             );
             #[cfg(windows)]
             let buffer_writer = &mut buffer_writer_lock;
-            #[cfg(unix)]
+            #[cfg(any(target_os = "android", target_os = "linux"))]
             let (stream, buffer_writer) = (
                 &mut sys_direction_output.async_playback_buffer_stream,
                 &mut sys_direction_output.buffer_writer,
diff --git a/devices/src/virtio/snd/mod.rs b/devices/src/virtio/snd/mod.rs
index 5498ea4..8f5d566 100644
--- a/devices/src/virtio/snd/mod.rs
+++ b/devices/src/virtio/snd/mod.rs
@@ -13,7 +13,7 @@
 pub mod null_backend;
 
 cfg_if::cfg_if! {
-    if #[cfg(unix)] {
+    if #[cfg(any(target_os = "android", target_os = "linux"))] {
         pub mod vios_backend;
 
         pub use vios_backend::new_sound;
diff --git a/devices/src/virtio/snd/sys/mod.rs b/devices/src/virtio/snd/sys/mod.rs
index 498aff8..89aafa1 100644
--- a/devices/src/virtio/snd/sys/mod.rs
+++ b/devices/src/virtio/snd/sys/mod.rs
@@ -3,7 +3,7 @@
 // found in the LICENSE file.
 
 cfg_if::cfg_if! {
-    if #[cfg(unix)] {
+    if #[cfg(any(target_os = "android", target_os = "linux"))] {
         mod unix;
         use unix as platform;
     } else if #[cfg(windows)] {
diff --git a/devices/src/virtio/vhost/mod.rs b/devices/src/virtio/vhost/mod.rs
index 67e9970..c74e0f4 100644
--- a/devices/src/virtio/vhost/mod.rs
+++ b/devices/src/virtio/vhost/mod.rs
@@ -9,7 +9,7 @@
 use net_util::Error as TapError;
 use remain::sorted;
 use thiserror::Error;
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 use vhost::Error as VhostError;
 
 mod control_socket;
@@ -18,7 +18,7 @@
 pub use self::control_socket::*;
 
 cfg_if::cfg_if! {
-    if #[cfg(unix)] {
+    if #[cfg(any(target_os = "android", target_os = "linux"))] {
         #[cfg(feature = "net")]
         mod net;
         pub mod vsock;
@@ -71,7 +71,7 @@
     #[error("failed to set vnet header size: {0}")]
     TapSetVnetHdrSize(TapError),
     /// Get features failed.
-    #[cfg(unix)]
+    #[cfg(any(target_os = "android", target_os = "linux"))]
     #[error("failed to get features: {0}")]
     VhostGetFeatures(VhostError),
     /// Vhost IOTLB required but not supported.
@@ -84,51 +84,51 @@
     #[error("failed to read vhost event: {0}")]
     VhostIrqRead(SysError),
     /// Net set backend failed.
-    #[cfg(unix)]
+    #[cfg(any(target_os = "android", target_os = "linux"))]
     #[error("net set backend failed: {0}")]
     VhostNetSetBackend(VhostError),
     /// Failed to open vhost device.
-    #[cfg(unix)]
+    #[cfg(any(target_os = "android", target_os = "linux"))]
     #[error("failed to open vhost device: {0}")]
     VhostOpen(VhostError),
     /// Set features failed.
-    #[cfg(unix)]
+    #[cfg(any(target_os = "android", target_os = "linux"))]
     #[error("failed to set features: {0}")]
     VhostSetFeatures(VhostError),
     /// Set mem table failed.
-    #[cfg(unix)]
+    #[cfg(any(target_os = "android", target_os = "linux"))]
     #[error("failed to set mem table: {0}")]
     VhostSetMemTable(VhostError),
     /// Set owner failed.
-    #[cfg(unix)]
+    #[cfg(any(target_os = "android", target_os = "linux"))]
     #[error("failed to set owner: {0}")]
     VhostSetOwner(VhostError),
     /// Set vring addr failed.
-    #[cfg(unix)]
+    #[cfg(any(target_os = "android", target_os = "linux"))]
     #[error("failed to set vring addr: {0}")]
     VhostSetVringAddr(VhostError),
     /// Set vring base failed.
-    #[cfg(unix)]
+    #[cfg(any(target_os = "android", target_os = "linux"))]
     #[error("failed to set vring base: {0}")]
     VhostSetVringBase(VhostError),
     /// Set vring call failed.
-    #[cfg(unix)]
+    #[cfg(any(target_os = "android", target_os = "linux"))]
     #[error("failed to set vring call: {0}")]
     VhostSetVringCall(VhostError),
     /// Set vring kick failed.
-    #[cfg(unix)]
+    #[cfg(any(target_os = "android", target_os = "linux"))]
     #[error("failed to set vring kick: {0}")]
     VhostSetVringKick(VhostError),
     /// Set vring num failed.
-    #[cfg(unix)]
+    #[cfg(any(target_os = "android", target_os = "linux"))]
     #[error("failed to set vring num: {0}")]
     VhostSetVringNum(VhostError),
     /// Failed to set CID for guest.
-    #[cfg(unix)]
+    #[cfg(any(target_os = "android", target_os = "linux"))]
     #[error("failed to set CID for guest: {0}")]
     VhostVsockSetCid(VhostError),
     /// Failed to start vhost-vsock driver.
-    #[cfg(unix)]
+    #[cfg(any(target_os = "android", target_os = "linux"))]
     #[error("failed to start vhost-vsock driver: {0}")]
     VhostVsockStart(VhostError),
     #[error("queue missing vring base")]
diff --git a/devices/src/virtio/vhost/user/device/block/sys.rs b/devices/src/virtio/vhost/user/device/block/sys.rs
index 31e6125..611487d 100644
--- a/devices/src/virtio/vhost/user/device/block/sys.rs
+++ b/devices/src/virtio/vhost/user/device/block/sys.rs
@@ -3,7 +3,7 @@
 // found in the LICENSE file.
 
 cfg_if::cfg_if! {
-    if #[cfg(unix)] {
+    if #[cfg(any(target_os = "android", target_os = "linux"))] {
         mod unix;
         use unix as platform;
     } else if #[cfg(windows)] {
diff --git a/devices/src/virtio/vhost/user/device/fs/sys.rs b/devices/src/virtio/vhost/user/device/fs/sys.rs
index de4269b..9f75a23 100644
--- a/devices/src/virtio/vhost/user/device/fs/sys.rs
+++ b/devices/src/virtio/vhost/user/device/fs/sys.rs
@@ -3,7 +3,7 @@
 // found in the LICENSE file.
 
 cfg_if::cfg_if! {
-    if #[cfg(unix)] {
+    if #[cfg(any(target_os = "android", target_os = "linux"))] {
         mod unix;
         use unix as platform;
     } else if #[cfg(windows)] {
diff --git a/devices/src/virtio/vhost/user/device/gpu/sys.rs b/devices/src/virtio/vhost/user/device/gpu/sys.rs
index d12b029..12cd759 100644
--- a/devices/src/virtio/vhost/user/device/gpu/sys.rs
+++ b/devices/src/virtio/vhost/user/device/gpu/sys.rs
@@ -3,7 +3,7 @@
 // found in the LICENSE file.
 
 cfg_if::cfg_if! {
-    if #[cfg(unix)] {
+    if #[cfg(any(target_os = "android", target_os = "linux"))] {
         pub mod unix;
         use unix as platform;
     } else if #[cfg(windows)] {
diff --git a/devices/src/virtio/vhost/user/device/handler.rs b/devices/src/virtio/vhost/user/device/handler.rs
index aa72f40..7c0e7ac 100644
--- a/devices/src/virtio/vhost/user/device/handler.rs
+++ b/devices/src/virtio/vhost/user/device/handler.rs
@@ -51,13 +51,13 @@
 use std::convert::From;
 use std::fs::File;
 use std::num::Wrapping;
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 use std::os::unix::io::AsRawFd;
 use std::sync::Arc;
 
 use anyhow::bail;
 use anyhow::Context;
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 use base::clear_fd_flags;
 use base::error;
 use base::Event;
@@ -360,7 +360,7 @@
         // Remove O_NONBLOCK from kick_fd. Otherwise, uring_executor will fails when we read
         // values via `next_val()` later.
         // This is only required (and can only be done) on Unix platforms.
-        #[cfg(unix)]
+        #[cfg(any(target_os = "android", target_os = "linux"))]
         if let Err(e) = clear_fd_flags(file.as_raw_fd(), libc::O_NONBLOCK) {
             error!("failed to remove O_NONBLOCK for kick fd: {}", e);
             return Err(VhostError::InvalidParam);
diff --git a/devices/src/virtio/vhost/user/device/handler/sys.rs b/devices/src/virtio/vhost/user/device/handler/sys.rs
index 9e87ad0..eb05c61 100644
--- a/devices/src/virtio/vhost/user/device/handler/sys.rs
+++ b/devices/src/virtio/vhost/user/device/handler/sys.rs
@@ -3,7 +3,7 @@
 // found in the LICENSE file.
 
 cfg_if::cfg_if! {
-    if #[cfg(unix)] {
+    if #[cfg(any(target_os = "android", target_os = "linux"))] {
         pub mod unix;
         #[cfg(test)]
         pub use unix::test_helpers;
diff --git a/devices/src/virtio/vhost/user/device/listener/sys.rs b/devices/src/virtio/vhost/user/device/listener/sys.rs
index a0f40a2..4137daf 100644
--- a/devices/src/virtio/vhost/user/device/listener/sys.rs
+++ b/devices/src/virtio/vhost/user/device/listener/sys.rs
@@ -3,7 +3,7 @@
 // found in the LICENSE file.
 
 cfg_if::cfg_if! {
-    if #[cfg(unix)] {
+    if #[cfg(any(target_os = "android", target_os = "linux"))] {
         pub mod unix;
         use unix as platform;
     } else if #[cfg(windows)] {
diff --git a/devices/src/virtio/vhost/user/device/mod.rs b/devices/src/virtio/vhost/user/device/mod.rs
index 7b013fd..75cebec 100644
--- a/devices/src/virtio/vhost/user/device/mod.rs
+++ b/devices/src/virtio/vhost/user/device/mod.rs
@@ -38,7 +38,7 @@
 use vmm_vhost::VhostUserSlaveReqHandler;
 
 cfg_if::cfg_if! {
-    if #[cfg(unix)] {
+    if #[cfg(any(target_os = "android", target_os = "linux"))] {
         mod console;
         mod fs;
         mod vsock;
diff --git a/devices/src/virtio/vhost/user/device/net/sys.rs b/devices/src/virtio/vhost/user/device/net/sys.rs
index 7e780a8..f6e029a 100644
--- a/devices/src/virtio/vhost/user/device/net/sys.rs
+++ b/devices/src/virtio/vhost/user/device/net/sys.rs
@@ -3,7 +3,7 @@
 // found in the LICENSE file.
 
 cfg_if::cfg_if! {
-    if #[cfg(unix)] {
+    if #[cfg(any(target_os = "android", target_os = "linux"))] {
         pub mod unix;
         use unix as platform;
     } else if #[cfg(windows)] {
diff --git a/devices/src/virtio/vhost/user/device/snd/sys.rs b/devices/src/virtio/vhost/user/device/snd/sys.rs
index c75e89c..3564f55 100644
--- a/devices/src/virtio/vhost/user/device/snd/sys.rs
+++ b/devices/src/virtio/vhost/user/device/snd/sys.rs
@@ -3,7 +3,7 @@
 // found in the LICENSE file.
 
 cfg_if::cfg_if! {
-    if #[cfg(unix)] {
+    if #[cfg(any(target_os = "android", target_os = "linux"))] {
         pub mod unix;
         use unix as platform;
     } else if #[cfg(windows)] {
diff --git a/devices/src/virtio/vhost/user/vmm/handler/sys.rs b/devices/src/virtio/vhost/user/vmm/handler/sys.rs
index af095a4..3a6cee3 100644
--- a/devices/src/virtio/vhost/user/vmm/handler/sys.rs
+++ b/devices/src/virtio/vhost/user/vmm/handler/sys.rs
@@ -3,7 +3,7 @@
 // found in the LICENSE file.
 
 cfg_if::cfg_if! {
-    if #[cfg(unix)] {
+    if #[cfg(any(target_os = "android", target_os = "linux"))] {
         mod unix;
         pub(super) use self::unix::*;
         use unix as platform;
diff --git a/devices/src/virtio/vhost/user/vmm/mod.rs b/devices/src/virtio/vhost/user/vmm/mod.rs
index e85ab49..543f9c4 100644
--- a/devices/src/virtio/vhost/user/vmm/mod.rs
+++ b/devices/src/virtio/vhost/user/vmm/mod.rs
@@ -25,7 +25,7 @@
 pub use self::handler::VhostUserHandler;
 
 cfg_if::cfg_if! {
-    if #[cfg(unix)] {
+    if #[cfg(any(target_os = "android", target_os = "linux"))] {
         pub type Connection = std::os::unix::net::UnixStream;
     } else if #[cfg(windows)] {
         pub type Connection = base::Tube;
diff --git a/devices/src/virtio/vsock/sys.rs b/devices/src/virtio/vsock/sys.rs
index 16eb60f..21c9c01 100644
--- a/devices/src/virtio/vsock/sys.rs
+++ b/devices/src/virtio/vsock/sys.rs
@@ -3,7 +3,7 @@
 // found in the LICENSE file.
 
 cfg_if::cfg_if! {
-    if #[cfg(unix)] {
+    if #[cfg(any(target_os = "android", target_os = "linux"))] {
         mod unix;
         use unix as platform;
         pub use crate::virtio::vhost::Vsock;
diff --git a/devices/src/virtio/vsock/sys/unix.rs b/devices/src/virtio/vsock/sys/unix.rs
index 291ecb7..3f9614f 100644
--- a/devices/src/virtio/vsock/sys/unix.rs
+++ b/devices/src/virtio/vsock/sys/unix.rs
@@ -33,7 +33,7 @@
     pub fn new<P: AsRef<Path>>(cid: u64, vhost_device: Option<P>) -> Self {
         Self {
             cid,
-            #[cfg(unix)]
+            #[cfg(any(target_os = "android", target_os = "linux"))]
             vhost_device: vhost_device
                 .map(|p| PathBuf::from(p.as_ref()))
                 .unwrap_or_else(|| PathBuf::from(VHOST_VSOCK_DEFAULT_PATH)),
@@ -77,7 +77,7 @@
         assert_eq!(
             from_vsock_arg("78").unwrap(),
             VsockConfig {
-                #[cfg(unix)]
+                #[cfg(any(target_os = "android", target_os = "linux"))]
                 vhost_device: VHOST_VSOCK_DEFAULT_PATH.into(),
                 cid: 78,
             }
diff --git a/devices/tests/irqchip/kvm/mod.rs b/devices/tests/irqchip/kvm/mod.rs
index 73e5afe..d816cf5 100644
--- a/devices/tests/irqchip/kvm/mod.rs
+++ b/devices/tests/irqchip/kvm/mod.rs
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#![cfg(unix)]
+#![cfg(any(target_os = "android", target_os = "linux"))]
 
 mod x86_64;
 
diff --git a/devices/tests/irqchip/userspace.rs b/devices/tests/irqchip/userspace.rs
index b4682e0..5166f0b 100644
--- a/devices/tests/irqchip/userspace.rs
+++ b/devices/tests/irqchip/userspace.rs
@@ -669,7 +669,7 @@
 
     fn set_immediate_exit(&self, _exit: bool) {}
 
-    #[cfg(unix)]
+    #[cfg(any(target_os = "android", target_os = "linux"))]
     fn signal_handle(&self) -> hypervisor::VcpuSignalHandle {
         unimplemented!()
     }
diff --git a/disk/src/sys.rs b/disk/src/sys.rs
index 3d15069..dc5fc7e 100644
--- a/disk/src/sys.rs
+++ b/disk/src/sys.rs
@@ -3,7 +3,7 @@
 // found in the LICENSE file.
 
 cfg_if::cfg_if! {
-    if #[cfg(unix)] {
+    if #[cfg(any(target_os = "android", target_os = "linux"))] {
         pub mod unix;
         use unix as platform;
     } else if #[cfg(windows)] {
diff --git a/docs/book/src/contributing/style_guide_platform_specific_code.md b/docs/book/src/contributing/style_guide_platform_specific_code.md
index 9cd8436..de61102 100644
--- a/docs/book/src/contributing/style_guide_platform_specific_code.md
+++ b/docs/book/src/contributing/style_guide_platform_specific_code.md
@@ -125,7 +125,7 @@
 
 ```rust
 cfg_if::cfg_if! {
-    if #[cfg(unix)] {
+    if #[cfg(any(target_os = "android", target_os = "linux"))] {
         mod unix;
         pub use platform_print::UnixPrinter as Printer;
     } else if #[cfg(windows)] {
@@ -137,13 +137,14 @@
 
 ## Imports
 
-When conditionally importing and using modules, use `cfg(unix)` and `cfg(windows)` for describing
-the platform. Order imports such that common comes first followed by unix and windows dependencies.
+When conditionally importing and using modules, use
+`cfg(any(target_os = "android", target_os = "linux"))` and `cfg(windows)` for describing the
+platform. Order imports such that common comes first followed by unix and windows dependencies.
 
 ```rust
 // All other imports
 
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 use {
   std::x::y,
   base::a::b::{Foo, Bar},
@@ -394,7 +395,7 @@
 
 ```rust
 cfg_if::cfg_if! {
-    if #[cfg(unix)] {
+    if #[cfg(any(target_os = "android", target_os = "linux"))] {
         pub mod unix;
         use unix as platform;
     } else if #[cfg(windows)] {
@@ -441,7 +442,7 @@
 fn my_print() {
   print();
 
-  #[cfg(unix)]
+  #[cfg(any(target_os = "android", target_os = "linux"))]
   mylib::sys::unix::print_u8(1);
 
   #[cfg(windows)]
diff --git a/e2e_tests/fixture/src/sys.rs b/e2e_tests/fixture/src/sys.rs
index 9264a52..93209e9 100644
--- a/e2e_tests/fixture/src/sys.rs
+++ b/e2e_tests/fixture/src/sys.rs
@@ -3,7 +3,7 @@
 // found in the LICENSE file.
 
 cfg_if::cfg_if! {
-    if #[cfg(unix)] {
+    if #[cfg(any(target_os = "android", target_os = "linux"))] {
         pub(super) mod unix;
         use unix as platform;
     } else if #[cfg(windows)] {
diff --git a/e2e_tests/fixture/src/utils.rs b/e2e_tests/fixture/src/utils.rs
index 7cea5b0..762c379 100644
--- a/e2e_tests/fixture/src/utils.rs
+++ b/e2e_tests/fixture/src/utils.rs
@@ -6,7 +6,7 @@
 
 use std::env;
 use std::io::ErrorKind;
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 use std::os::unix::process::ExitStatusExt;
 use std::path::Path;
 use std::path::PathBuf;
@@ -126,7 +126,7 @@
             if let Some(code) = output.status.code() {
                 return Err(CommandError::ErrorCode(code));
             } else {
-                #[cfg(unix)]
+                #[cfg(any(target_os = "android", target_os = "linux"))]
                 if let Some(signal) = output.status.signal() {
                     return Err(CommandError::Signal(signal));
                 }
diff --git a/e2e_tests/guest_under_test/rootfs/delegate/src/main.rs b/e2e_tests/guest_under_test/rootfs/delegate/src/main.rs
index bb9b6b5..b5f4bc4 100644
--- a/e2e_tests/guest_under_test/rootfs/delegate/src/main.rs
+++ b/e2e_tests/guest_under_test/rootfs/delegate/src/main.rs
@@ -9,7 +9,7 @@
 use std::fs::File;
 use std::io;
 use std::io::prelude::*;
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 use std::os::unix::process::ExitStatusExt;
 use std::path::Path;
 use std::process::Command;
@@ -53,7 +53,7 @@
                         stderr: String::from_utf8_lossy(&result.stderr).into_owned(),
                         exit_status: match result.status.code() {
                             Some(code) => wire_format::ExitStatus::Code(code),
-                            #[cfg(unix)]
+                            #[cfg(any(target_os = "android", target_os = "linux"))]
                             None => match result.status.signal() {
                                 Some(signal) => wire_format::ExitStatus::Signal(signal),
                                 None => wire_format::ExitStatus::None,
diff --git a/e2e_tests/tests/block.rs b/e2e_tests/tests/block.rs
index 7b9d79a..edf6e74 100644
--- a/e2e_tests/tests/block.rs
+++ b/e2e_tests/tests/block.rs
@@ -4,7 +4,7 @@
 
 //! Testing virtio-block.
 
-#![cfg(unix)]
+#![cfg(any(target_os = "android", target_os = "linux"))]
 
 use std::time;
 
diff --git a/e2e_tests/tests/boot.rs b/e2e_tests/tests/boot.rs
index 405a9f6..14d98ce 100644
--- a/e2e_tests/tests/boot.rs
+++ b/e2e_tests/tests/boot.rs
@@ -44,21 +44,21 @@
     Ok(())
 }
 
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 #[test]
 fn boot_test_vm_odirect() {
     let mut vm = TestVm::new(Config::new().o_direct()).unwrap();
     assert_eq!(vm.exec_in_guest("echo 42").unwrap().stdout.trim(), "42");
 }
 
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 #[test]
 fn boot_test_vm_config_file() {
     let mut vm = TestVm::new_with_config_file(Config::new()).unwrap();
     assert_eq!(vm.exec_in_guest("echo 42").unwrap().stdout.trim(), "42");
 }
 
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 #[test]
 fn boot_test_suspend_resume() {
     // There is no easy way for us to check if the VM is actually suspended. But at
@@ -69,7 +69,7 @@
     assert_eq!(vm.exec_in_guest("echo 42").unwrap().stdout.trim(), "42");
 }
 
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 #[test]
 fn boot_test_suspend_resume_full() {
     // There is no easy way for us to check if the VM is actually suspended. But at
@@ -88,28 +88,28 @@
     assert_eq!(vm.exec_in_guest("echo 42").unwrap().stdout.trim(), "42");
 }
 
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 #[test]
 fn boot_test_vm_disable_sandbox() {
     let mut vm = TestVm::new(Config::new().disable_sandbox()).unwrap();
     assert_eq!(vm.exec_in_guest("echo 42").unwrap().stdout.trim(), "42");
 }
 
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 #[test]
 fn boot_test_vm_disable_sandbox_odirect() {
     let mut vm = TestVm::new(Config::new().disable_sandbox().o_direct()).unwrap();
     assert_eq!(vm.exec_in_guest("echo 42").unwrap().stdout.trim(), "42");
 }
 
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 #[test]
 fn boot_test_vm_disable_sandbox_config_file() {
     let mut vm = TestVm::new_with_config_file(Config::new().disable_sandbox()).unwrap();
     assert_eq!(vm.exec_in_guest("echo 42").unwrap().stdout.trim(), "42");
 }
 
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 #[test]
 fn boot_test_disable_sandbox_suspend_resume() {
     // There is no easy way for us to check if the VM is actually suspended. But at
diff --git a/e2e_tests/tests/fs.rs b/e2e_tests/tests/fs.rs
index 358c8ea..4d273ea 100644
--- a/e2e_tests/tests/fs.rs
+++ b/e2e_tests/tests/fs.rs
@@ -56,7 +56,7 @@
 /// 3. Start a VM with a virtiofs device for the temporal directory.
 /// 4. Check that `user_file.txt`'s uid is <mapped-uid> in the VM.
 /// 5. Verify gid similarly.
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 #[test]
 fn file_ugid() {
     const FILE_NAME: &str = "user_file.txt";
diff --git a/e2e_tests/tests/suspend_resume.rs b/e2e_tests/tests/suspend_resume.rs
index 677c705..f33eb1b 100644
--- a/e2e_tests/tests/suspend_resume.rs
+++ b/e2e_tests/tests/suspend_resume.rs
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#![cfg(unix)]
+#![cfg(any(target_os = "android", target_os = "linux"))]
 
 use std::io::Write;
 use std::path::Path;
diff --git a/e2e_tests/tests/swap.rs b/e2e_tests/tests/swap.rs
index 5b33b81..7f05d83 100644
--- a/e2e_tests/tests/swap.rs
+++ b/e2e_tests/tests/swap.rs
@@ -4,7 +4,7 @@
 
 //! Testing vmm-swap
 
-#![cfg(unix)]
+#![cfg(any(target_os = "android", target_os = "linux"))]
 
 use std::time::Duration;
 use std::time::Instant;
diff --git a/e2e_tests/tests/vsock.rs b/e2e_tests/tests/vsock.rs
index eb163e0..dd314a9 100644
--- a/e2e_tests/tests/vsock.rs
+++ b/e2e_tests/tests/vsock.rs
@@ -4,7 +4,7 @@
 
 //! Testing vsock.
 
-#![cfg(unix)]
+#![cfg(any(target_os = "android", target_os = "linux"))]
 
 use std::io::Write;
 use std::path::Path;
diff --git a/fuse/src/lib.rs b/fuse/src/lib.rs
index 95e4b2c..6fe9c43 100644
--- a/fuse/src/lib.rs
+++ b/fuse/src/lib.rs
@@ -4,7 +4,7 @@
 
 //! FUSE (Filesystem in Userspace) server and filesystem mounting support.
 
-#![cfg(unix)]
+#![cfg(any(target_os = "android", target_os = "linux"))]
 
 use std::ffi::FromBytesWithNulError;
 use std::fs::File;
diff --git a/fuzz/fuzz_targets/fs_server_fuzzer.rs b/fuzz/fuzz_targets/fs_server_fuzzer.rs
index f606719..c49f9bf 100644
--- a/fuzz/fuzz_targets/fs_server_fuzzer.rs
+++ b/fuzz/fuzz_targets/fs_server_fuzzer.rs
@@ -5,7 +5,7 @@
 #![cfg(not(test))]
 #![no_main]
 
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 mod fuzzer {
     use std::convert::TryInto;
 
diff --git a/fuzz/fuzz_targets/p9_tframe_fuzzer.rs b/fuzz/fuzz_targets/p9_tframe_fuzzer.rs
index 5b86b71..d776a3a 100644
--- a/fuzz/fuzz_targets/p9_tframe_fuzzer.rs
+++ b/fuzz/fuzz_targets/p9_tframe_fuzzer.rs
@@ -9,6 +9,6 @@
 use crosvm_fuzz::fuzz_target;
 
 fuzz_target!(|bytes: &[u8]| {
-    #[cfg(unix)]
+    #[cfg(any(target_os = "android", target_os = "linux"))]
     p9::fuzzing::tframe_decode(bytes);
 });
diff --git a/gpu_display/examples/simple.rs b/gpu_display/examples/simple.rs
index 27ed9ad..f82aba3 100644
--- a/gpu_display/examples/simple.rs
+++ b/gpu_display/examples/simple.rs
@@ -4,7 +4,7 @@
 
 use std::process::exit;
 
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 mod platform {
     use anyhow::Context;
     use anyhow::Result;
diff --git a/gpu_display/src/lib.rs b/gpu_display/src/lib.rs
index c8877d7..b350f57 100644
--- a/gpu_display/src/lib.rs
+++ b/gpu_display/src/lib.rs
@@ -24,7 +24,7 @@
 mod gpu_display_stub;
 #[cfg(windows)]
 mod gpu_display_win;
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 mod gpu_display_wl;
 #[cfg(feature = "x")]
 mod gpu_display_x;
diff --git a/gpu_display/src/sys/mod.rs b/gpu_display/src/sys/mod.rs
index 8733412..0df919e 100644
--- a/gpu_display/src/sys/mod.rs
+++ b/gpu_display/src/sys/mod.rs
@@ -3,7 +3,7 @@
 // found in the LICENSE file.
 
 cfg_if::cfg_if! {
-    if #[cfg(unix)] {
+    if #[cfg(any(target_os = "android", target_os = "linux"))] {
         pub(crate) mod unix;
         pub use unix::UnixGpuDisplayExt as SysGpuDisplayExt;
         pub(crate) use unix::UnixDisplayT as SysDisplayT;
diff --git a/hypervisor/Cargo.toml b/hypervisor/Cargo.toml
index e8cbf77..8df30b7 100644
--- a/hypervisor/Cargo.toml
+++ b/hypervisor/Cargo.toml
@@ -31,7 +31,7 @@
 base = { path = "../base" }
 vm_memory = { path = "../vm_memory" }
 
-[target.'cfg(unix)'.dependencies]
+[target.'cfg(any(target_os = "android", target_os = "linux"))'.dependencies]
 kvm = { path = "../kvm" }
 kvm_sys = { path = "../kvm_sys" }
 
diff --git a/hypervisor/src/geniezone/geniezone_sys/mod.rs b/hypervisor/src/geniezone/geniezone_sys/mod.rs
index 1fb8c06..0a9c57e 100644
--- a/hypervisor/src/geniezone/geniezone_sys/mod.rs
+++ b/hypervisor/src/geniezone/geniezone_sys/mod.rs
@@ -4,7 +4,7 @@
 
 //! Bindings for the GZVM (Geniezone Hypervisor) API.
 
-#![cfg(unix)]
+#![cfg(any(target_os = "android", target_os = "linux"))]
 #![allow(non_upper_case_globals)]
 #![allow(non_camel_case_types)]
 #![allow(non_snake_case)]
diff --git a/hypervisor/src/haxm.rs b/hypervisor/src/haxm.rs
index 12d28f5..8492a99 100644
--- a/hypervisor/src/haxm.rs
+++ b/hypervisor/src/haxm.rs
@@ -35,9 +35,9 @@
 #[cfg(windows)]
 use win::*;
 
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 mod unix;
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 use unix::*;
 
 static USE_GHAXM: AtomicBool = AtomicBool::new(true);
diff --git a/hypervisor/src/haxm/haxm_sys.rs b/hypervisor/src/haxm/haxm_sys.rs
index 1c28f91..9f1431f 100644
--- a/hypervisor/src/haxm/haxm_sys.rs
+++ b/hypervisor/src/haxm/haxm_sys.rs
@@ -22,7 +22,7 @@
 #[cfg(windows)]
 pub use win::*;
 
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 mod posix;
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 pub use posix::*;
diff --git a/hypervisor/src/lib.rs b/hypervisor/src/lib.rs
index 06683d0..9e2c959 100644
--- a/hypervisor/src/lib.rs
+++ b/hypervisor/src/lib.rs
@@ -15,7 +15,7 @@
 pub mod gunyah;
 #[cfg(all(windows, feature = "haxm"))]
 pub mod haxm;
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 pub mod kvm;
 #[cfg(target_arch = "riscv64")]
 pub mod riscv64;
@@ -235,12 +235,12 @@
 }
 
 /// Handle to a virtual CPU that may be used to request a VM exit from within a signal handler.
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 pub struct VcpuSignalHandle {
     inner: Box<dyn VcpuSignalHandleInner>,
 }
 
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 impl VcpuSignalHandle {
     /// Request an immediate exit for this VCPU.
     ///
@@ -253,7 +253,7 @@
 /// Signal-safe mechanism for requesting an immediate VCPU exit.
 ///
 /// Each hypervisor backend must implement this for its VCPU type.
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 pub(crate) trait VcpuSignalHandleInner {
     /// Signal the associated VCPU to exit if it is currently running.
     ///
@@ -286,7 +286,7 @@
 
     /// Returns a handle that can be used to cause this VCPU to exit from `run()` from a signal
     /// handler.
-    #[cfg(unix)]
+    #[cfg(any(target_os = "android", target_os = "linux"))]
     fn signal_handle(&self) -> VcpuSignalHandle;
 
     /// Handles an incoming MMIO request from the guest.
diff --git a/hypervisor/tests/dirty_log.rs b/hypervisor/tests/dirty_log.rs
index 4d9c463..8a2cba6 100644
--- a/hypervisor/tests/dirty_log.rs
+++ b/hypervisor/tests/dirty_log.rs
@@ -3,7 +3,7 @@
 // found in the LICENSE file.
 
 // TODO(b/237714823): Currently, only kvm is enabled for this test once LUCI can run windows.
-#![cfg(unix)]
+#![cfg(any(target_os = "android", target_os = "linux"))]
 #![cfg(target_arch = "x86_64")]
 #![cfg(any(feature = "whpx", feature = "gvm", feature = "haxm", unix))]
 
@@ -14,7 +14,7 @@
 use vm_memory::GuestMemory;
 
 #[test]
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 fn test_kvm_dirty_log() {
     use hypervisor::kvm::*;
     test_dirty_log(|guest_mem| {
diff --git a/hypervisor/tests/kvm/main.rs b/hypervisor/tests/kvm/main.rs
index e970d48..e4ebc20 100644
--- a/hypervisor/tests/kvm/main.rs
+++ b/hypervisor/tests/kvm/main.rs
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#![cfg(unix)]
+#![cfg(any(target_os = "android", target_os = "linux"))]
 
 #[cfg(any(target_arch = "arm", target_arch = "aarch64"))]
 mod aarch64;
diff --git a/hypervisor/tests/mmio_and_pio.rs b/hypervisor/tests/mmio_and_pio.rs
index 3ad2daa..2bf748b 100644
--- a/hypervisor/tests/mmio_and_pio.rs
+++ b/hypervisor/tests/mmio_and_pio.rs
@@ -3,7 +3,7 @@
 // found in the LICENSE file.
 
 // TODO(b/237714823): Currently, only kvm is enabled for this test once LUCI can run windows.
-#![cfg(unix)]
+#![cfg(any(target_os = "android", target_os = "linux"))]
 #![cfg(target_arch = "x86_64")]
 
 use std::sync::atomic::AtomicU16;
@@ -14,7 +14,7 @@
 use vm_memory::GuestMemory;
 
 #[test]
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 fn test_kvm_mmio_and_pio() {
     use hypervisor::kvm::*;
     test_mmio_and_pio(|guest_mem| {
diff --git a/hypervisor/tests/read_only_memory.rs b/hypervisor/tests/read_only_memory.rs
index 1435380..6610f94 100644
--- a/hypervisor/tests/read_only_memory.rs
+++ b/hypervisor/tests/read_only_memory.rs
@@ -3,7 +3,7 @@
 // found in the LICENSE file.
 
 // TODO(b/237714823): Currently, only kvm is enabled for this test once LUCI can run windows.
-#![cfg(unix)]
+#![cfg(any(target_os = "android", target_os = "linux"))]
 #![cfg(target_arch = "x86_64")]
 
 use std::sync::atomic::AtomicU16;
@@ -16,7 +16,7 @@
 use vm_memory::GuestMemory;
 
 #[test]
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 fn test_kvm_read_only_memory() {
     use hypervisor::kvm::*;
     test_read_only_memory(|guest_mem| {
diff --git a/hypervisor/tests/real_run_addr.rs b/hypervisor/tests/real_run_addr.rs
index 8b2ef10..ec3f050 100644
--- a/hypervisor/tests/real_run_addr.rs
+++ b/hypervisor/tests/real_run_addr.rs
@@ -3,7 +3,7 @@
 // found in the LICENSE file.
 
 // TODO(b/237714823): Currently, only kvm is enabled for this test once LUCI can run windows.
-#![cfg(unix)]
+#![cfg(any(target_os = "android", target_os = "linux"))]
 #![cfg(target_arch = "x86_64")]
 
 use hypervisor::*;
@@ -12,7 +12,7 @@
 use vm_memory::GuestMemory;
 
 #[test]
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 fn test_kvm_real_run_addr() {
     use hypervisor::kvm::*;
     test_real_run_addr(|guest_mem| {
diff --git a/hypervisor/tests/remove_memory.rs b/hypervisor/tests/remove_memory.rs
index e8fcd8b..4ca5fcc 100644
--- a/hypervisor/tests/remove_memory.rs
+++ b/hypervisor/tests/remove_memory.rs
@@ -3,7 +3,7 @@
 // found in the LICENSE file.
 
 // TODO(b/237714823): Currently, only kvm is enabled for this test once LUCI can run windows.
-#![cfg(unix)]
+#![cfg(any(target_os = "android", target_os = "linux"))]
 #![cfg(target_arch = "x86_64")]
 
 use base::MemoryMappingBuilder;
@@ -13,7 +13,7 @@
 use vm_memory::GuestMemory;
 
 #[test]
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 fn test_kvm_remove_memory() {
     use hypervisor::kvm::*;
     test_remove_memory(|guest_mem| {
diff --git a/hypervisor/tests/tsc_offsets.rs b/hypervisor/tests/tsc_offsets.rs
index e75e037..1f4e9d3 100644
--- a/hypervisor/tests/tsc_offsets.rs
+++ b/hypervisor/tests/tsc_offsets.rs
@@ -3,7 +3,7 @@
 // found in the LICENSE file.
 
 // TODO(b/237714823): Currently, only kvm is enabled for this test once LUCI can run windows.
-#![cfg(unix)]
+#![cfg(any(target_os = "android", target_os = "linux"))]
 #![cfg(target_arch = "x86_64")]
 
 use std::arch::x86_64::_rdtsc;
@@ -28,7 +28,7 @@
 }
 
 #[test]
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 fn test_kvm_tsc_offsets() {
     use hypervisor::kvm::*;
     test_tsc_offsets(|guest_mem| {
diff --git a/io_uring/src/lib.rs b/io_uring/src/lib.rs
index 54c7734..ea8c592 100644
--- a/io_uring/src/lib.rs
+++ b/io_uring/src/lib.rs
@@ -4,7 +4,7 @@
 
 //! Safe wrapper over the Linux `io_uring` system calls.
 
-#![cfg(unix)]
+#![cfg(any(target_os = "android", target_os = "linux"))]
 
 mod bindings;
 mod syscalls;
diff --git a/io_uring/tests/uring.rs b/io_uring/tests/uring.rs
index 2b2c640..406aff0 100644
--- a/io_uring/tests/uring.rs
+++ b/io_uring/tests/uring.rs
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#![cfg(unix)]
+#![cfg(any(target_os = "android", target_os = "linux"))]
 
 use std::collections::BTreeSet;
 use std::fs::File;
diff --git a/jail/Cargo.toml b/jail/Cargo.toml
index bb2b179..6b1353f 100644
--- a/jail/Cargo.toml
+++ b/jail/Cargo.toml
@@ -17,7 +17,7 @@
 static_assertions = "*"
 zerocopy = { version = "0.7", features = ["derive"] }
 
-[target.'cfg(unix)'.dependencies]
+[target.'cfg(any(target_os = "android", target_os = "linux"))'.dependencies]
 minijail = "*"
 
 [build-dependencies]
diff --git a/jail/src/config.rs b/jail/src/config.rs
index cb19450..681db29 100644
--- a/jail/src/config.rs
+++ b/jail/src/config.rs
@@ -17,7 +17,7 @@
 pub struct JailConfig {
     #[serde(default = "jail_config_default_pivot_root")]
     pub pivot_root: PathBuf,
-    #[cfg(unix)]
+    #[cfg(any(target_os = "android", target_os = "linux"))]
     #[serde(default)]
     pub seccomp_policy_dir: Option<PathBuf>,
     #[serde(default)]
@@ -28,7 +28,7 @@
     fn default() -> Self {
         JailConfig {
             pivot_root: jail_config_default_pivot_root(),
-            #[cfg(unix)]
+            #[cfg(any(target_os = "android", target_os = "linux"))]
             seccomp_policy_dir: None,
             seccomp_log_failures: false,
         }
@@ -48,7 +48,7 @@
             config,
             JailConfig {
                 pivot_root: jail_config_default_pivot_root(),
-                #[cfg(unix)]
+                #[cfg(any(target_os = "android", target_os = "linux"))]
                 seccomp_policy_dir: None,
                 seccomp_log_failures: false,
             }
@@ -67,7 +67,7 @@
         );
 
         cfg_if::cfg_if! {
-            if #[cfg(unix)] {
+            if #[cfg(any(target_os = "android", target_os = "linux"))] {
                 let config: JailConfig =
                     from_key_values("seccomp-policy-dir=/path/to/seccomp/dir").unwrap();
                 assert_eq!(config, JailConfig {
diff --git a/jail/src/lib.rs b/jail/src/lib.rs
index 6f3a4dd..97316de 100644
--- a/jail/src/lib.rs
+++ b/jail/src/lib.rs
@@ -3,11 +3,11 @@
 // found in the LICENSE file.
 
 mod config;
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 mod helpers;
 
 pub use crate::config::JailConfig;
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 pub use crate::helpers::*;
 
 // TODO(b/268407006): We define Minijail as an empty struct as a stub for minijail::Minijail on
diff --git a/kvm/src/lib.rs b/kvm/src/lib.rs
index 66d16e8..e713739 100644
--- a/kvm/src/lib.rs
+++ b/kvm/src/lib.rs
@@ -6,7 +6,7 @@
 //!
 //! New code should use the `hypervisor` crate instead.
 
-#![cfg(unix)]
+#![cfg(any(target_os = "android", target_os = "linux"))]
 
 mod cap;
 
diff --git a/kvm/tests/dirty_log.rs b/kvm/tests/dirty_log.rs
index 485282a..1273b0b 100644
--- a/kvm/tests/dirty_log.rs
+++ b/kvm/tests/dirty_log.rs
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#![cfg(unix)]
+#![cfg(any(target_os = "android", target_os = "linux"))]
 #![cfg(target_arch = "x86_64")]
 
 use base::MemoryMappingBuilder;
diff --git a/kvm/tests/kvm_tests.rs b/kvm/tests/kvm_tests.rs
index 3c7387b..1b79bcc 100644
--- a/kvm/tests/kvm_tests.rs
+++ b/kvm/tests/kvm_tests.rs
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#![cfg(unix)]
+#![cfg(any(target_os = "android", target_os = "linux"))]
 
 use base::pagesize;
 use base::Event;
diff --git a/kvm/tests/read_only_memory.rs b/kvm/tests/read_only_memory.rs
index 2052511..94be4a9 100644
--- a/kvm/tests/read_only_memory.rs
+++ b/kvm/tests/read_only_memory.rs
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#![cfg(unix)]
+#![cfg(any(target_os = "android", target_os = "linux"))]
 #![cfg(target_arch = "x86_64")]
 
 use base::MemoryMappingBuilder;
diff --git a/kvm/tests/real_run_adder.rs b/kvm/tests/real_run_adder.rs
index fddddf4..26a6ae6 100644
--- a/kvm/tests/real_run_adder.rs
+++ b/kvm/tests/real_run_adder.rs
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#![cfg(unix)]
+#![cfg(any(target_os = "android", target_os = "linux"))]
 #![cfg(target_arch = "x86_64")]
 
 use kvm::*;
diff --git a/kvm_sys/src/lib.rs b/kvm_sys/src/lib.rs
index ed27e02..3b4a848 100644
--- a/kvm_sys/src/lib.rs
+++ b/kvm_sys/src/lib.rs
@@ -4,7 +4,7 @@
 
 //! Bindings for the Linux KVM (Kernel Virtual Machine) API.
 
-#![cfg(unix)]
+#![cfg(any(target_os = "android", target_os = "linux"))]
 #![allow(non_upper_case_globals)]
 #![allow(non_camel_case_types)]
 #![allow(non_snake_case)]
diff --git a/media/ffmpeg/src/lib.rs b/media/ffmpeg/src/lib.rs
index 4e775ed..7ea9856 100644
--- a/media/ffmpeg/src/lib.rs
+++ b/media/ffmpeg/src/lib.rs
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#![cfg(unix)]
+#![cfg(any(target_os = "android", target_os = "linux"))]
 
 pub mod avcodec;
 mod avutil;
diff --git a/media/libvda/src/lib.rs b/media/libvda/src/lib.rs
index 5c78174..1916719 100644
--- a/media/libvda/src/lib.rs
+++ b/media/libvda/src/lib.rs
@@ -4,7 +4,7 @@
 
 //! Bindings for the `libvda` video decoder and encoder libraries.
 
-#![cfg(unix)]
+#![cfg(any(target_os = "android", target_os = "linux"))]
 
 pub mod decode;
 pub mod encode;
diff --git a/media/libvda/tests/decode_tests.rs b/media/libvda/tests/decode_tests.rs
index c649341..e1d8150 100644
--- a/media/libvda/tests/decode_tests.rs
+++ b/media/libvda/tests/decode_tests.rs
@@ -4,7 +4,7 @@
 
 //! Integration tests using LibVDA fake decode implemenation.
 
-#![cfg(unix)]
+#![cfg(any(target_os = "android", target_os = "linux"))]
 
 use libvda::decode::*;
 use libvda::*;
diff --git a/media/libvda/tests/encode_tests.rs b/media/libvda/tests/encode_tests.rs
index e35e98d..629fe0a 100644
--- a/media/libvda/tests/encode_tests.rs
+++ b/media/libvda/tests/encode_tests.rs
@@ -4,7 +4,7 @@
 
 //! Integration tests using LibVDA fake encode implementation.
 
-#![cfg(unix)]
+#![cfg(any(target_os = "android", target_os = "linux"))]
 
 use libvda::encode::*;
 use libvda::*;
diff --git a/metrics/src/sys.rs b/metrics/src/sys.rs
index 150f561..4c526e3 100644
--- a/metrics/src/sys.rs
+++ b/metrics/src/sys.rs
@@ -6,7 +6,7 @@
     if #[cfg(windows)] {
         pub mod windows;
         pub use windows::*;
-    } else if #[cfg(unix)] {
+    } else if #[cfg(any(target_os = "android", target_os = "linux"))] {
         pub(crate) mod unix;
     }
 }
diff --git a/net_util/src/sys.rs b/net_util/src/sys.rs
index 052a9c6..40aa4e4 100644
--- a/net_util/src/sys.rs
+++ b/net_util/src/sys.rs
@@ -3,7 +3,7 @@
 // found in the LICENSE file.
 
 cfg_if::cfg_if! {
-    if #[cfg(unix)] {
+    if #[cfg(any(target_os = "android", target_os = "linux"))] {
         pub mod unix;
         use unix as platform;
     } else if #[cfg(windows)] {
diff --git a/net_util/tests/unix_tap.rs b/net_util/tests/unix_tap.rs
index a81d69a..35d4912 100644
--- a/net_util/tests/unix_tap.rs
+++ b/net_util/tests/unix_tap.rs
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#![cfg(unix)]
+#![cfg(any(target_os = "android", target_os = "linux"))]
 
 use std::net;
 
diff --git a/perfetto/build.rs b/perfetto/build.rs
index e829777..f4e80e0 100644
--- a/perfetto/build.rs
+++ b/perfetto/build.rs
@@ -9,7 +9,7 @@
     #[cfg(windows)]
     main_windows();
 
-    #[cfg(unix)]
+    #[cfg(any(target_os = "android", target_os = "linux"))]
     main_unix();
 
     // TODO: enable once Perfetto is in third_party/perfetto.
@@ -37,7 +37,7 @@
     */
 }
 
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 fn main_unix() {
     // TODO: enable once we have Perfetto libraries available on unix. We may
     // want to use a prebuilt here too, in which case this would be identical
diff --git a/prebuilts/src/lib.rs b/prebuilts/src/lib.rs
index c2227f5..965d342 100644
--- a/prebuilts/src/lib.rs
+++ b/prebuilts/src/lib.rs
@@ -126,7 +126,7 @@
         dest_path.link, dest_path.file
     );
     let _ = std::fs::remove_file(&dest_path.link);
-    #[cfg(unix)]
+    #[cfg(any(target_os = "android", target_os = "linux"))]
     std::os::unix::fs::symlink(&dest_path.file, &dest_path.link)?;
     #[cfg(windows)]
     let _ = std::fs::copy(&dest_path.file, &dest_path.link)?;
diff --git a/prebuilts/src/sys.rs b/prebuilts/src/sys.rs
index ad52bf3..f5eb509 100644
--- a/prebuilts/src/sys.rs
+++ b/prebuilts/src/sys.rs
@@ -3,7 +3,7 @@
 // found in the LICENSE file.
 
 cfg_if::cfg_if! {
-    if #[cfg(unix)] {
+    if #[cfg(any(target_os = "android", target_os = "linux"))] {
         pub(crate) mod unix;
         pub(crate) use unix::*;
     } else if #[cfg(windows)] {
diff --git a/protos/src/plugin.rs b/protos/src/plugin.rs
index b1b1c5d..c12e60e 100644
--- a/protos/src/plugin.rs
+++ b/protos/src/plugin.rs
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#![cfg(unix)]
+#![cfg(any(target_os = "android", target_os = "linux"))]
 
 pub use crate::generated::plugin::*;
 
diff --git a/riscv64/Cargo.toml b/riscv64/Cargo.toml
index 89566f6..6592fbe 100644
--- a/riscv64/Cargo.toml
+++ b/riscv64/Cargo.toml
@@ -28,5 +28,5 @@
 vm_control = { path = "../vm_control" }
 vm_memory = { path = "../vm_memory" }
 
-[target.'cfg(unix)'.dependencies]
+[target.'cfg(any(target_os = "android", target_os = "linux"))'.dependencies]
 minijail = "*"
diff --git a/riscv64/src/lib.rs b/riscv64/src/lib.rs
index d5620a4..e4f77d8 100644
--- a/riscv64/src/lib.rs
+++ b/riscv64/src/lib.rs
@@ -45,13 +45,13 @@
 use hypervisor::VmRiscv64;
 #[cfg(windows)]
 use jail::FakeMinijailStub as Minijail;
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 use minijail::Minijail;
 use remain::sorted;
 use resources::AddressRange;
 use resources::SystemAllocator;
 use resources::SystemAllocatorConfig;
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 use sync::Condvar;
 use sync::Mutex;
 use thiserror::Error;
@@ -188,7 +188,9 @@
         _dump_device_tree_blob: Option<PathBuf>,
         _debugcon_jail: Option<Minijail>,
         #[cfg(feature = "swap")] swap_controller: &mut Option<swap::SwapController>,
-        #[cfg(unix)] _guest_suspended_cvar: Option<Arc<(Mutex<bool>, Condvar)>>,
+        #[cfg(any(target_os = "android", target_os = "linux"))] _guest_suspended_cvar: Option<
+            Arc<(Mutex<bool>, Condvar)>,
+        >,
     ) -> std::result::Result<RunnableLinuxVm<V, Vcpu>, Self::Error>
     where
         V: VmRiscv64,
diff --git a/rutabaga_gfx/Cargo.toml b/rutabaga_gfx/Cargo.toml
index 0f5c89c..33d3281 100644
--- a/rutabaga_gfx/Cargo.toml
+++ b/rutabaga_gfx/Cargo.toml
@@ -26,7 +26,7 @@
 
 log = "0.4"
 
-[target.'cfg(unix)'.dependencies]
+[target.'cfg(any(target_os = "android", target_os = "linux"))'.dependencies]
 nix = "0.26.1"
 
 [target.'cfg(windows)'.dependencies]
diff --git a/rutabaga_gfx/src/rutabaga_gralloc/vulkano_gralloc/sys.rs b/rutabaga_gfx/src/rutabaga_gralloc/vulkano_gralloc/sys.rs
index 7ca32b7..3698871 100644
--- a/rutabaga_gfx/src/rutabaga_gralloc/vulkano_gralloc/sys.rs
+++ b/rutabaga_gfx/src/rutabaga_gralloc/vulkano_gralloc/sys.rs
@@ -3,7 +3,7 @@
 // found in the LICENSE file.
 
 cfg_if::cfg_if! {
-    if #[cfg(unix)] {
+    if #[cfg(any(target_os = "android", target_os = "linux"))] {
         pub mod unix;
     } else if #[cfg(windows)] {
         pub mod windows;
diff --git a/rutabaga_gfx/src/rutabaga_utils.rs b/rutabaga_gfx/src/rutabaga_utils.rs
index c8cdbdc..c8215d1 100644
--- a/rutabaga_gfx/src/rutabaga_utils.rs
+++ b/rutabaga_gfx/src/rutabaga_utils.rs
@@ -14,7 +14,7 @@
 use std::str::Utf8Error;
 use std::sync::Arc;
 
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 use nix::Error as NixError;
 use remain::sorted;
 use thiserror::Error;
@@ -268,7 +268,7 @@
     #[error("The mapping failed with library error: {0}")]
     MappingFailed(i32),
     /// Nix crate error.
-    #[cfg(unix)]
+    #[cfg(any(target_os = "android", target_os = "linux"))]
     #[error("The errno is {0}")]
     NixError(NixError),
     #[error("Nul Error occured {0}")]
@@ -315,7 +315,7 @@
     VkMemoryMapError(MemoryMapError),
 }
 
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 impl From<NixError> for RutabagaError {
     fn from(e: NixError) -> RutabagaError {
         RutabagaError::NixError(e)
diff --git a/src/crosvm/cmdline.rs b/src/crosvm/cmdline.rs
index 243c305..fb2de80 100644
--- a/src/crosvm/cmdline.rs
+++ b/src/crosvm/cmdline.rs
@@ -3,7 +3,7 @@
 // found in the LICENSE file.
 
 cfg_if::cfg_if! {
-    if #[cfg(unix)] {
+    if #[cfg(any(target_os = "android", target_os = "linux"))] {
         use base::RawDescriptor;
         use devices::virtio::vhost::user::device::parse_wayland_sock;
 
@@ -1028,7 +1028,7 @@
     /// context ID for virtual sockets.
     pub cid: Option<u64>,
 
-    #[cfg(unix)]
+    #[cfg(any(target_os = "android", target_os = "linux"))]
     #[argh(
         option,
         arg_name = "unpin_policy=POLICY,unpin_interval=NUM,unpin_limit=NUM,unpin_gen_threshold=NUM"
@@ -1432,14 +1432,14 @@
     /// path to a socket from where to read keyboard input events and write status updates to
     pub keyboard: Vec<PathBuf>,
 
-    #[cfg(unix)]
+    #[cfg(any(target_os = "android", target_os = "linux"))]
     #[argh(option, arg_name = "PATH")]
     #[serde(skip)] // Deprecated - use `hypervisor` instead.
     #[merge(strategy = overwrite_option)]
     /// path to the KVM device. (default /dev/kvm)
     pub kvm_device: Option<PathBuf>,
 
-    #[cfg(unix)]
+    #[cfg(any(target_os = "android", target_os = "linux"))]
     #[argh(switch)]
     #[serde(skip)] // TODO(b/255223604)
     #[merge(strategy = overwrite_option)]
@@ -1611,7 +1611,7 @@
     /// extra kernel or plugin command line arguments. Can be given more than once
     pub params: Vec<String>,
 
-    #[cfg(unix)]
+    #[cfg(any(target_os = "android", target_os = "linux"))]
     #[argh(option, arg_name = "pci_hotplug_slots")]
     #[serde(default)]
     #[merge(strategy = overwrite_option)]
@@ -1868,14 +1868,14 @@
     // TODO(b/300580119): Add O_DIRECT and sparse file support.
     scsi_block: Vec<ScsiOption>,
 
-    #[cfg(unix)]
+    #[cfg(any(target_os = "android", target_os = "linux"))]
     #[argh(switch)]
     #[serde(skip)] // TODO(b/255223604)
     #[merge(strategy = overwrite_option)]
     /// instead of seccomp filter failures being fatal, they will be logged instead
     pub seccomp_log_failures: Option<bool>,
 
-    #[cfg(unix)]
+    #[cfg(any(target_os = "android", target_os = "linux"))]
     #[argh(option, arg_name = "PATH")]
     #[serde(skip)] // TODO(b/255223604)
     #[merge(strategy = overwrite_option)]
@@ -1923,7 +1923,7 @@
     /// the service ipc pipe name. (Prefix \\\\.\\pipe\\ not needed.
     pub service_pipe_name: Option<String>,
 
-    #[cfg(unix)]
+    #[cfg(any(target_os = "android", target_os = "linux"))]
     #[argh(
         option,
         arg_name = "PATH:TAG[:type=TYPE:writeback=BOOL:timeout=SECONDS:uidmap=UIDMAP:gidmap=GIDMAP:cache=CACHE:dax=BOOL,posix_acl=BOOL]"
@@ -2098,14 +2098,14 @@
     /// when logging to syslog, use the provided tag
     pub syslog_tag: Option<String>,
 
-    #[cfg(unix)]
+    #[cfg(any(target_os = "android", target_os = "linux"))]
     #[argh(option)]
     #[serde(skip)] // Deprecated - use `net` instead.
     #[merge(strategy = append)]
     /// file descriptor for configured tap device. A different virtual network card will be added each time this argument is given
     pub tap_fd: Vec<RawDescriptor>,
 
-    #[cfg(unix)]
+    #[cfg(any(target_os = "android", target_os = "linux"))]
     #[argh(option)]
     #[serde(skip)] // Deprecated - use `net` instead.
     #[merge(strategy = append)]
@@ -2125,7 +2125,7 @@
     /// path to a socket from where to read trackpad input events and write status updates to, optionally followed by screen width and height (defaults to 800x1280) and a name for the input device
     pub trackpad: Vec<TouchDeviceOption>,
 
-    #[cfg(unix)]
+    #[cfg(any(target_os = "android", target_os = "linux"))]
     #[argh(switch)]
     #[serde(skip)] // TODO(b/255223604)
     #[merge(strategy = overwrite_option)]
@@ -2151,7 +2151,7 @@
     /// move all vCPU threads to this CGroup (default: nothing moves)
     pub vcpu_cgroup_path: Option<PathBuf>,
 
-    #[cfg(unix)]
+    #[cfg(any(target_os = "android", target_os = "linux"))]
     #[argh(
         option,
         arg_name = "PATH[,guest-address=<BUS:DEVICE.FUNCTION>][,iommu=viommu|coiommu|off]"
@@ -2168,35 +2168,35 @@
     ///        to use for this device.
     pub vfio: Vec<VfioOption>,
 
-    #[cfg(unix)]
+    #[cfg(any(target_os = "android", target_os = "linux"))]
     #[argh(switch)]
     #[serde(skip)] // TODO(b/255223604)
     #[merge(strategy = overwrite_option)]
     /// isolate all hotplugged passthrough vfio device behind virtio-iommu
     pub vfio_isolate_hotplug: Option<bool>,
 
-    #[cfg(unix)]
+    #[cfg(any(target_os = "android", target_os = "linux"))]
     #[argh(option, arg_name = "PATH")]
     #[serde(skip)] // Deprecated - use `vfio` instead.
     #[merge(strategy = append)]
     /// path to sysfs of platform pass through
     pub vfio_platform: Vec<VfioOption>,
 
-    #[cfg(unix)]
+    #[cfg(any(target_os = "android", target_os = "linux"))]
     #[argh(switch)]
     #[serde(skip)] // Deprecated - use `net` instead.
     #[merge(strategy = overwrite_option)]
     /// use vhost for networking
     pub vhost_net: Option<bool>,
 
-    #[cfg(unix)]
+    #[cfg(any(target_os = "android", target_os = "linux"))]
     #[argh(option, arg_name = "PATH")]
     #[serde(skip)] // TODO(b/255223604)
     #[merge(strategy = overwrite_option)]
     /// path to the vhost-net device. (default /dev/vhost-net)
     pub vhost_net_device: Option<PathBuf>,
 
-    #[cfg(unix)]
+    #[cfg(any(target_os = "android", target_os = "linux"))]
     #[cfg(any(target_arch = "arm", target_arch = "aarch64"))]
     #[argh(switch)]
     #[merge(strategy = overwrite_option)]
@@ -2267,14 +2267,14 @@
     /// path to a vhost-user socket for wayland
     pub vhost_user_wl: Option<VhostUserOption>,
 
-    #[cfg(unix)]
+    #[cfg(any(target_os = "android", target_os = "linux"))]
     #[argh(option, arg_name = "SOCKET_PATH")]
     #[serde(skip)] // Deprecated - use `vsock` instead.
     #[merge(strategy = overwrite_option)]
     /// path to the vhost-vsock device. (default /dev/vhost-vsock)
     pub vhost_vsock_device: Option<PathBuf>,
 
-    #[cfg(unix)]
+    #[cfg(any(target_os = "android", target_os = "linux"))]
     #[argh(option, arg_name = "FD")]
     #[serde(skip)] // Deprecated - use `vsock` instead.
     #[merge(strategy = overwrite_option)]
@@ -2353,14 +2353,14 @@
     /// enable the virtio-tpm connection to vtpm daemon
     pub vtpm_proxy: Option<bool>,
 
-    #[cfg(unix)]
+    #[cfg(any(target_os = "android", target_os = "linux"))]
     #[argh(option, arg_name = "PATH[,name=NAME]", from_str_fn(parse_wayland_sock))]
     #[serde(skip)] // TODO(b/255223604)
     #[merge(strategy = append)]
     /// path to the Wayland socket to use. The unnamed one is used for displaying virtual screens. Named ones are only for IPC
     pub wayland_sock: Vec<(String, PathBuf)>,
 
-    #[cfg(unix)]
+    #[cfg(any(target_os = "android", target_os = "linux"))]
     #[argh(option, arg_name = "DISPLAY")]
     #[serde(skip)] // TODO(b/255223604)
     #[merge(strategy = overwrite_option)]
@@ -2415,7 +2415,7 @@
             cfg.executable_path = Some(Executable::Kernel(p));
         }
 
-        #[cfg(unix)]
+        #[cfg(any(target_os = "android", target_os = "linux"))]
         if let Some(p) = cmd.kvm_device {
             log::warn!(
                 "`--kvm-device <PATH>` is deprecated; use `--hypervisor kvm[device=<PATH>]` instead"
@@ -2534,7 +2534,7 @@
             cfg.hypervisor = cmd.hypervisor;
         }
 
-        #[cfg(unix)]
+        #[cfg(any(target_os = "android", target_os = "linux"))]
         {
             cfg.lock_guest_memory = cmd.lock_guest_memory.unwrap_or_default();
         }
@@ -2705,7 +2705,7 @@
 
         cfg.fw_cfg_parameters = cmd.fw_cfg;
 
-        #[cfg(unix)]
+        #[cfg(any(target_os = "android", target_os = "linux"))]
         for (name, params) in cmd.wayland_sock {
             if cfg.wayland_socket_paths.contains_key(&name) {
                 return Err(format!("wayland socket name already used: '{}'", name));
@@ -2713,7 +2713,7 @@
             cfg.wayland_socket_paths.insert(name, params);
         }
 
-        #[cfg(unix)]
+        #[cfg(any(target_os = "android", target_os = "linux"))]
         {
             cfg.x_display = cmd.x_display;
         }
@@ -2746,7 +2746,7 @@
 
             let legacy_vsock_config = VsockConfig::new(
                 cid,
-                #[cfg(unix)]
+                #[cfg(any(target_os = "android", target_os = "linux"))]
                 match (cmd.vhost_vsock_device, cmd.vhost_vsock_fd) {
                     (Some(_), Some(_)) => {
                         return Err(
@@ -2812,7 +2812,7 @@
             }
         }
 
-        #[cfg(unix)]
+        #[cfg(any(target_os = "android", target_os = "linux"))]
         #[cfg(any(target_arch = "arm", target_arch = "aarch64"))]
         {
             cfg.vhost_scmi = cmd.vhost_scmi.unwrap_or_default();
@@ -2906,7 +2906,7 @@
                 }
             }
 
-            #[cfg(unix)]
+            #[cfg(any(target_os = "android", target_os = "linux"))]
             {
                 cfg.gpu_cgroup_path = cmd.gpu_cgroup_path;
                 cfg.gpu_server_cgroup_path = cmd.gpu_server_cgroup_path;
@@ -3026,7 +3026,7 @@
             }
         }
 
-        #[cfg(unix)]
+        #[cfg(any(target_os = "android", target_os = "linux"))]
         {
             cfg.shared_dirs = cmd.shared_dir;
 
@@ -3174,7 +3174,7 @@
             cfg.task_profiles = cmd.task_profiles;
         }
 
-        #[cfg(unix)]
+        #[cfg(any(target_os = "android", target_os = "linux"))]
         {
             if cmd.unmap_guest_memory_on_fork.unwrap_or_default()
                 && !cmd.disable_sandbox.unwrap_or_default()
@@ -3184,7 +3184,7 @@
             cfg.unmap_guest_memory_on_fork = cmd.unmap_guest_memory_on_fork.unwrap_or_default();
         }
 
-        #[cfg(unix)]
+        #[cfg(any(target_os = "android", target_os = "linux"))]
         {
             cfg.vfio.extend(cmd.vfio);
             cfg.vfio.extend(cmd.vfio_platform);
diff --git a/src/crosvm/config.rs b/src/crosvm/config.rs
index 0910d77..dd6cc84 100644
--- a/src/crosvm/config.rs
+++ b/src/crosvm/config.rs
@@ -57,11 +57,11 @@
 use x86_64::CpuIdCall;
 
 pub(crate) use super::sys::HypervisorKind;
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 use crate::crosvm::sys::config::SharedDir;
 
 cfg_if::cfg_if! {
-    if #[cfg(unix)] {
+    if #[cfg(any(target_os = "android", target_os = "linux"))] {
         #[cfg(feature = "gpu")]
         use crate::crosvm::sys::GpuRenderServerParameters;
 
@@ -764,7 +764,7 @@
     pub broker_shutdown_event: Option<Event>,
     #[cfg(all(target_arch = "x86_64", unix))]
     pub bus_lock_ratelimit: u64,
-    #[cfg(unix)]
+    #[cfg(any(target_os = "android", target_os = "linux"))]
     pub coiommu_param: Option<devices::CoIommuParameters>,
     pub core_scheduling: bool,
     pub cpu_capacity: BTreeMap<usize, u32>, // CPU index -> capacity
@@ -815,7 +815,7 @@
     pub jail_config: Option<JailConfig>,
     #[cfg(windows)]
     pub kernel_log_file: Option<String>,
-    #[cfg(unix)]
+    #[cfg(any(target_os = "android", target_os = "linux"))]
     pub lock_guest_memory: bool,
     #[cfg(windows)]
     pub log_file: Option<String>,
@@ -871,7 +871,7 @@
     pub serial_parameters: BTreeMap<(SerialHardware, u8), SerialParameters>,
     #[cfg(windows)]
     pub service_pipe_name: Option<String>,
-    #[cfg(unix)]
+    #[cfg(any(target_os = "android", target_os = "linux"))]
     #[serde(skip)]
     pub shared_dirs: Vec<SharedDir>,
     #[cfg(any(feature = "slirp-ring-capture", feature = "slirp-debug"))]
@@ -890,7 +890,7 @@
     pub swiotlb: Option<u64>,
     #[cfg(target_os = "android")]
     pub task_profiles: Vec<String>,
-    #[cfg(unix)]
+    #[cfg(any(target_os = "android", target_os = "linux"))]
     pub unmap_guest_memory_on_fork: bool,
     pub usb: bool,
     pub vcpu_affinity: Option<VcpuAffinity>,
@@ -898,14 +898,14 @@
     pub vcpu_count: Option<usize>,
     #[cfg(target_arch = "x86_64")]
     pub vcpu_hybrid_type: BTreeMap<usize, CpuHybridType>, // CPU index -> hybrid type
-    #[cfg(unix)]
+    #[cfg(any(target_os = "android", target_os = "linux"))]
     pub vfio: Vec<super::sys::config::VfioOption>,
-    #[cfg(unix)]
+    #[cfg(any(target_os = "android", target_os = "linux"))]
     pub vfio_isolate_hotplug: bool,
-    #[cfg(unix)]
+    #[cfg(any(target_os = "android", target_os = "linux"))]
     #[cfg(any(target_arch = "arm", target_arch = "aarch64"))]
     pub vhost_scmi: bool,
-    #[cfg(unix)]
+    #[cfg(any(target_os = "android", target_os = "linux"))]
     #[cfg(any(target_arch = "arm", target_arch = "aarch64"))]
     pub vhost_scmi_device: PathBuf,
     pub vhost_user_blk: Vec<VhostUserOption>,
@@ -966,7 +966,7 @@
             broker_shutdown_event: None,
             #[cfg(all(target_arch = "x86_64", unix))]
             bus_lock_ratelimit: 0,
-            #[cfg(unix)]
+            #[cfg(any(target_os = "android", target_os = "linux"))]
             coiommu_param: None,
             core_scheduling: true,
             #[cfg(feature = "crash-report")]
@@ -1025,7 +1025,7 @@
             },
             #[cfg(windows)]
             kernel_log_file: None,
-            #[cfg(unix)]
+            #[cfg(any(target_os = "android", target_os = "linux"))]
             lock_guest_memory: false,
             #[cfg(windows)]
             log_file: None,
@@ -1075,7 +1075,7 @@
             scsis: Vec::new(),
             #[cfg(windows)]
             service_pipe_name: None,
-            #[cfg(unix)]
+            #[cfg(any(target_os = "android", target_os = "linux"))]
             shared_dirs: Vec::new(),
             #[cfg(any(feature = "slirp-ring-capture", feature = "slirp-debug"))]
             slirp_capture_file: None,
@@ -1093,7 +1093,7 @@
             swiotlb: None,
             #[cfg(target_os = "android")]
             task_profiles: Vec::new(),
-            #[cfg(unix)]
+            #[cfg(any(target_os = "android", target_os = "linux"))]
             unmap_guest_memory_on_fork: false,
             usb: true,
             vcpu_affinity: None,
@@ -1101,14 +1101,14 @@
             vcpu_count: None,
             #[cfg(target_arch = "x86_64")]
             vcpu_hybrid_type: BTreeMap::new(),
-            #[cfg(unix)]
+            #[cfg(any(target_os = "android", target_os = "linux"))]
             vfio: Vec::new(),
-            #[cfg(unix)]
+            #[cfg(any(target_os = "android", target_os = "linux"))]
             vfio_isolate_hotplug: false,
-            #[cfg(unix)]
+            #[cfg(any(target_os = "android", target_os = "linux"))]
             #[cfg(any(target_arch = "arm", target_arch = "aarch64"))]
             vhost_scmi: false,
-            #[cfg(unix)]
+            #[cfg(any(target_os = "android", target_os = "linux"))]
             #[cfg(any(target_arch = "arm", target_arch = "aarch64"))]
             vhost_scmi_device: PathBuf::from(VHOST_SCMI_PATH),
             vhost_user_blk: Vec::new(),
@@ -1277,7 +1277,7 @@
         return Err("'balloon_page_reporting' requires enabled balloon".to_string());
     }
 
-    #[cfg(unix)]
+    #[cfg(any(target_os = "android", target_os = "linux"))]
     if cfg.lock_guest_memory && cfg.jail_config.is_none() {
         return Err("'lock-guest-memory' and 'disable-sandbox' are mutually exclusive".to_string());
     }
diff --git a/src/crosvm/gpu_config.rs b/src/crosvm/gpu_config.rs
index ad5fb94..0e99c34 100644
--- a/src/crosvm/gpu_config.rs
+++ b/src/crosvm/gpu_config.rs
@@ -711,7 +711,7 @@
         );
     }
 
-    #[cfg(unix)]
+    #[cfg(any(target_os = "android", target_os = "linux"))]
     #[test]
     fn parse_gpu_options_and_gpu_display_options_multi_display_supported_on_unix() {
         {
diff --git a/src/crosvm/sys.rs b/src/crosvm/sys.rs
index a49990a..473f580 100644
--- a/src/crosvm/sys.rs
+++ b/src/crosvm/sys.rs
@@ -2,14 +2,14 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 pub(crate) mod unix;
 
 #[cfg(windows)]
 pub(crate) mod windows;
 
 cfg_if::cfg_if! {
-    if #[cfg(unix)] {
+    if #[cfg(any(target_os = "android", target_os = "linux"))] {
         use unix as platform;
 
         #[cfg(feature = "gpu")]
diff --git a/src/crosvm/sys/unix/cmdline.rs b/src/crosvm/sys/unix/cmdline.rs
index ab68b26..271ff3f 100644
--- a/src/crosvm/sys/unix/cmdline.rs
+++ b/src/crosvm/sys/unix/cmdline.rs
@@ -130,6 +130,6 @@
 #[argh(subcommand)]
 /// Unix Commands
 pub enum Commands {
-    #[cfg(unix)]
+    #[cfg(any(target_os = "android", target_os = "linux"))]
     Devices(DevicesCommand),
 }
diff --git a/src/sys.rs b/src/sys.rs
index 3d27c7e..abcccd7 100644
--- a/src/sys.rs
+++ b/src/sys.rs
@@ -3,7 +3,7 @@
 // found in the LICENSE file.
 
 cfg_if::cfg_if! {
-    if #[cfg(unix)] {
+    if #[cfg(any(target_os = "android", target_os = "linux"))] {
         pub(crate) mod unix;
         use unix as platform;
         pub(crate) use crate::crosvm::sys::unix::{run_config, ExitState};
diff --git a/swap/Cargo.toml b/swap/Cargo.toml
index 7e5d664..a261ea4 100644
--- a/swap/Cargo.toml
+++ b/swap/Cargo.toml
@@ -33,7 +33,7 @@
 thiserror = "*"
 vm_memory = { path = "../vm_memory"}
 
-[target.'cfg(unix)'.dependencies]
+[target.'cfg(any(target_os = "android", target_os = "linux"))'.dependencies]
 libc = "*"
 
 [target.'cfg(target_os="linux")'.dependencies]
diff --git a/system_api/Cargo.toml b/system_api/Cargo.toml
index 7efcc4e..df0db0c 100644
--- a/system_api/Cargo.toml
+++ b/system_api/Cargo.toml
@@ -7,6 +7,6 @@
 [lib]
 path = "src/system_api.rs"
 
-[target.'cfg(unix)'.dependencies]
+[target.'cfg(any(target_os = "android", target_os = "linux"))'.dependencies]
 dbus = "0.9"
 protobuf = "3.2"
diff --git a/system_api/src/system_api.rs b/system_api/src/system_api.rs
index 9a79cd2..e57fc74 100644
--- a/system_api/src/system_api.rs
+++ b/system_api/src/system_api.rs
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#![cfg(unix)]
+#![cfg(any(target_os = "android", target_os = "linux"))]
 
 include!("bindings/include_modules.rs");
 include!("protos/include_protos.rs");
diff --git a/third_party/vmm_vhost/src/connection.rs b/third_party/vmm_vhost/src/connection.rs
index 5cf25d2..18bccfe 100644
--- a/third_party/vmm_vhost/src/connection.rs
+++ b/third_party/vmm_vhost/src/connection.rs
@@ -4,7 +4,7 @@
 //! Common data structures for listener and endpoint.
 
 cfg_if::cfg_if! {
-    if #[cfg(unix)] {
+    if #[cfg(any(target_os = "android", target_os = "linux"))] {
         pub mod socket;
         mod unix;
     } else if #[cfg(windows)] {
@@ -447,7 +447,7 @@
 pub(crate) mod tests {
     use super::*;
     cfg_if::cfg_if! {
-        if #[cfg(unix)] {
+        if #[cfg(any(target_os = "android", target_os = "linux"))] {
             #[cfg(feature = "vmm")]
             pub(crate) use super::unix::tests::*;
         } else if #[cfg(windows)] {
diff --git a/third_party/vmm_vhost/src/lib.rs b/third_party/vmm_vhost/src/lib.rs
index be3b01a..e8960ab 100644
--- a/third_party/vmm_vhost/src/lib.rs
+++ b/third_party/vmm_vhost/src/lib.rs
@@ -462,7 +462,7 @@
         let descriptor =
             unsafe { tube_transporter::packed_tube::pack(tubes.0, std::process::id()).unwrap() };
 
-        #[cfg(unix)]
+        #[cfg(any(target_os = "android", target_os = "linux"))]
         let descriptor = base::Event::new().unwrap();
 
         master.set_slave_request_fd(&descriptor).unwrap();
diff --git a/third_party/vmm_vhost/src/master_req_handler.rs b/third_party/vmm_vhost/src/master_req_handler.rs
index fd51361..e39258f 100644
--- a/third_party/vmm_vhost/src/master_req_handler.rs
+++ b/third_party/vmm_vhost/src/master_req_handler.rs
@@ -2,7 +2,7 @@
 // SPDX-License-Identifier: Apache-2.0
 
 cfg_if::cfg_if! {
-    if #[cfg(unix)] {
+    if #[cfg(any(target_os = "android", target_os = "linux"))] {
         mod unix;
     } else if #[cfg(windows)] {
         mod windows;
diff --git a/third_party/vmm_vhost/src/sys.rs b/third_party/vmm_vhost/src/sys.rs
index 999acec..fdca302 100644
--- a/third_party/vmm_vhost/src/sys.rs
+++ b/third_party/vmm_vhost/src/sys.rs
@@ -4,7 +4,7 @@
 //! A wrapper module for platform dependent code.
 
 cfg_if::cfg_if! {
-    if #[cfg(unix)] {
+    if #[cfg(any(target_os = "android", target_os = "linux"))] {
         pub mod unix;
         use unix as platform;
     } else if #[cfg(windows)] {
diff --git a/usb_util/src/lib.rs b/usb_util/src/lib.rs
index e816417..3963f13 100644
--- a/usb_util/src/lib.rs
+++ b/usb_util/src/lib.rs
@@ -5,7 +5,7 @@
 //! USB device access and descriptor manipulation.
 
 mod descriptor;
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 mod device;
 mod error;
 mod types;
@@ -14,17 +14,17 @@
 pub use self::descriptor::ConfigDescriptorTree;
 pub use self::descriptor::DeviceDescriptorTree;
 pub use self::descriptor::InterfaceDescriptorTree;
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 pub use self::device::Device;
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 pub use self::device::DmaBuffer;
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 pub use self::device::Transfer;
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 pub use self::device::TransferBuffer;
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 pub use self::device::TransferHandle;
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 pub use self::device::TransferStatus;
 pub use self::error::Error;
 pub use self::error::Result;
diff --git a/vendor/generic/crash_report/src/lib.rs b/vendor/generic/crash_report/src/lib.rs
index e050c6f..7e73f26 100644
--- a/vendor/generic/crash_report/src/lib.rs
+++ b/vendor/generic/crash_report/src/lib.rs
@@ -13,7 +13,7 @@
 #[cfg(windows)]
 use win_util::ProcessType;
 
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 pub enum ProcessType {}
 
 /// The reason a SimulatedException crash report is being requested.
diff --git a/vhost/src/lib.rs b/vhost/src/lib.rs
index 0d97064..b5c8993 100644
--- a/vhost/src/lib.rs
+++ b/vhost/src/lib.rs
@@ -4,10 +4,10 @@
 
 //! Linux vhost kernel API wrapper.
 
-#![cfg(unix)]
+#![cfg(any(target_os = "android", target_os = "linux"))]
 
 pub mod net;
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 #[cfg(any(target_arch = "arm", target_arch = "aarch64"))]
 mod scmi;
 mod vsock;
@@ -30,11 +30,11 @@
 use vm_memory::GuestMemory;
 use vm_memory::GuestMemoryError;
 
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 pub use crate::net::Net;
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 pub use crate::net::NetT;
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 #[cfg(any(target_arch = "arm", target_arch = "aarch64"))]
 pub use crate::scmi::Scmi;
 pub use crate::vsock::Vsock;
diff --git a/vhost/tests/unix.rs b/vhost/tests/unix.rs
index dd36052..9a6893f 100644
--- a/vhost/tests/unix.rs
+++ b/vhost/tests/unix.rs
@@ -3,7 +3,7 @@
 // found in the LICENSE file.
 
 // TODO(225193541): Enable/add tests for windows.
-#![cfg(unix)]
+#![cfg(any(target_os = "android", target_os = "linux"))]
 
 use std::path::PathBuf;
 use std::result;
diff --git a/vm_control/src/client.rs b/vm_control/src/client.rs
index bb16414..b8ca6a3 100644
--- a/vm_control/src/client.rs
+++ b/vm_control/src/client.rs
@@ -16,7 +16,7 @@
 #[cfg(feature = "gpu")]
 pub use crate::gpu::*;
 pub use crate::sys::handle_request;
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 pub use crate::sys::handle_request_with_timeout;
 pub use crate::*;
 
diff --git a/vm_control/src/lib.rs b/vm_control/src/lib.rs
index 80dec6c..816204e 100644
--- a/vm_control/src/lib.rs
+++ b/vm_control/src/lib.rs
@@ -16,7 +16,7 @@
 #[cfg(feature = "gpu")]
 pub mod gpu;
 
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 use base::MemoryMappingBuilderUnix;
 #[cfg(windows)]
 use base::MemoryMappingBuilderWindows;
@@ -89,11 +89,11 @@
 use serde::Serialize;
 use swap::SwapStatus;
 use sync::Mutex;
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 pub use sys::FsMappingRequest;
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 pub use sys::VmMsyncRequest;
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 pub use sys::VmMsyncResponse;
 use thiserror::Error;
 pub use vm_control_product::GpuSendToMain;
diff --git a/vm_control/src/sys.rs b/vm_control/src/sys.rs
index 7fcd726..9e59b7b 100644
--- a/vm_control/src/sys.rs
+++ b/vm_control/src/sys.rs
@@ -3,7 +3,7 @@
 // found in the LICENSE file.
 
 cfg_if::cfg_if! {
-    if #[cfg(unix)] {
+    if #[cfg(any(target_os = "android", target_os = "linux"))] {
         pub mod unix;
         use unix as platform;
         pub use platform::{VmMsyncRequest, VmMsyncResponse, FsMappingRequest};
diff --git a/vm_memory/src/guest_memory/sys.rs b/vm_memory/src/guest_memory/sys.rs
index 0b4ceee..e67f6f2 100644
--- a/vm_memory/src/guest_memory/sys.rs
+++ b/vm_memory/src/guest_memory/sys.rs
@@ -3,7 +3,7 @@
 // found in the LICENSE file.
 
 cfg_if::cfg_if! {
-    if #[cfg(unix)] {
+    if #[cfg(any(target_os = "android", target_os = "linux"))] {
         pub mod unix;
         use unix as platform;
     } else if #[cfg(windows)] {
diff --git a/vm_memory/src/udmabuf/sys.rs b/vm_memory/src/udmabuf/sys.rs
index 46c0247..e66bf4c 100644
--- a/vm_memory/src/udmabuf/sys.rs
+++ b/vm_memory/src/udmabuf/sys.rs
@@ -3,7 +3,7 @@
 // found in the LICENSE file.
 
 cfg_if::cfg_if! {
-    if #[cfg(unix)] {
+    if #[cfg(any(target_os = "android", target_os = "linux"))] {
         pub mod unix;
         pub use unix::UnixUdmabufDriver as UdmabufDriver;
     } else if #[cfg(windows)] {
diff --git a/x86_64/Cargo.toml b/x86_64/Cargo.toml
index f3bac70..db81275 100644
--- a/x86_64/Cargo.toml
+++ b/x86_64/Cargo.toml
@@ -37,5 +37,5 @@
 vm_memory = { path = "../vm_memory" }
 zerocopy = { version = "0.7", features = ["derive"] }
 
-[target.'cfg(unix)'.dependencies]
+[target.'cfg(any(target_os = "android", target_os = "linux"))'.dependencies]
 minijail = "*"
diff --git a/x86_64/src/lib.rs b/x86_64/src/lib.rs
index d64233a..fbde8af 100644
--- a/x86_64/src/lib.rs
+++ b/x86_64/src/lib.rs
@@ -60,7 +60,7 @@
 #[cfg(feature = "seccomp_trace")]
 use base::debug;
 use base::warn;
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 use base::AsRawDescriptors;
 use base::Event;
 use base::SendTube;
@@ -86,12 +86,12 @@
 use devices::PciRootCommand;
 use devices::PciVirtualConfigMmio;
 use devices::Pflash;
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 use devices::ProxyDevice;
 use devices::Serial;
 use devices::SerialHardware;
 use devices::SerialParameters;
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 use devices::VirtualPmc;
 use devices::FW_CFG_BASE_PORT;
 use devices::FW_CFG_MAX_FILE_SLOTS;
@@ -121,7 +121,7 @@
 use jail::read_jail_addr;
 #[cfg(windows)]
 use jail::FakeMinijailStub as Minijail;
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 use minijail::Minijail;
 use once_cell::sync::OnceCell;
 use rand::rngs::OsRng;
@@ -130,7 +130,7 @@
 use resources::AddressRange;
 use resources::SystemAllocator;
 use resources::SystemAllocatorConfig;
-#[cfg(unix)]
+#[cfg(any(target_os = "android", target_os = "linux"))]
 use sync::Condvar;
 use sync::Mutex;
 use thiserror::Error;
@@ -160,7 +160,7 @@
     CloneEvent(base::Error),
     #[error("failed to clone IRQ chip: {0}")]
     CloneIrqChip(base::Error),
-    #[cfg(unix)]
+    #[cfg(any(target_os = "android", target_os = "linux"))]
     #[error("failed to clone jail: {0}")]
     CloneJail(minijail::Error),
     #[error("unable to clone a Tube: {0}")]
@@ -193,7 +193,7 @@
     CreatePit(base::Error),
     #[error("unable to make PIT device: {0}")]
     CreatePitDevice(devices::PitError),
-    #[cfg(unix)]
+    #[cfg(any(target_os = "android", target_os = "linux"))]
     #[error("unable to create proxy device: {0}")]
     CreateProxyDevice(devices::ProxyError),
     #[error("unable to create serial devices: {0}")]
@@ -685,7 +685,9 @@
         pflash_jail: Option<Minijail>,
         fw_cfg_jail: Option<Minijail>,
         #[cfg(feature = "swap")] swap_controller: &mut Option<swap::SwapController>,
-        #[cfg(unix)] guest_suspended_cvar: Option<Arc<(Mutex<bool>, Condvar)>>,
+        #[cfg(any(target_os = "android", target_os = "linux"))] guest_suspended_cvar: Option<
+            Arc<(Mutex<bool>, Condvar)>,
+        >,
     ) -> std::result::Result<RunnableLinuxVm<V, Vcpu>, Self::Error>
     where
         V: VmX86_64,
@@ -889,9 +891,9 @@
             &mut resume_notify_devices,
             #[cfg(feature = "swap")]
             swap_controller,
-            #[cfg(unix)]
+            #[cfg(any(target_os = "android", target_os = "linux"))]
             components.ac_adapter,
-            #[cfg(unix)]
+            #[cfg(any(target_os = "android", target_os = "linux"))]
             guest_suspended_cvar,
             &pci_irqs,
         )?;
@@ -1031,7 +1033,7 @@
             gdb: components.gdb,
             pm: Some(acpi_dev_resource.pm),
             root_config: pci,
-            #[cfg(unix)]
+            #[cfg(any(target_os = "android", target_os = "linux"))]
             platform_devices: Vec::new(),
             hotplug_bus: BTreeMap::new(),
             devices_thread: None,
@@ -1093,7 +1095,7 @@
     fn register_pci_device<V: VmX86_64, Vcpu: VcpuX86_64>(
         linux: &mut RunnableLinuxVm<V, Vcpu>,
         device: Box<dyn PciDevice>,
-        #[cfg(unix)] minijail: Option<Minijail>,
+        #[cfg(any(target_os = "android", target_os = "linux"))] minijail: Option<Minijail>,
         resources: &mut SystemAllocator,
         hp_control_tube: &mpsc::Sender<PciRootCommand>,
         #[cfg(feature = "swap")] swap_controller: &mut Option<swap::SwapController>,
@@ -1101,7 +1103,7 @@
         arch::configure_pci_device(
             linux,
             device,
-            #[cfg(unix)]
+            #[cfg(any(target_os = "android", target_os = "linux"))]
             minijail,
             resources,
             hp_control_tube,
@@ -1525,12 +1527,12 @@
         let start = FIRST_ADDR_PAST_32BITS - bios_size - size;
         let pflash_image = Box::new(pflash_image);
 
-        #[cfg(unix)]
+        #[cfg(any(target_os = "android", target_os = "linux"))]
         let fds = pflash_image.as_raw_descriptors();
 
         let pflash = Pflash::new(pflash_image, block_size).map_err(Error::SetupPflash)?;
         let pflash: Arc<Mutex<dyn BusDevice>> = match jail {
-            #[cfg(unix)]
+            #[cfg(any(target_os = "android", target_os = "linux"))]
             Some(jail) => Arc::new(Mutex::new(
                 ProxyDevice::new(
                     pflash,
@@ -1733,7 +1735,7 @@
         };
 
         let fw_cfg: Arc<Mutex<dyn BusDevice>> = match fw_cfg_jail.as_ref() {
-            #[cfg(unix)]
+            #[cfg(any(target_os = "android", target_os = "linux"))]
             Some(jail) => {
                 let jail_clone = jail.try_clone().map_err(Error::CloneJail)?;
                 #[cfg(feature = "seccomp_trace")]
@@ -1870,8 +1872,10 @@
         max_bus: u8,
         resume_notify_devices: &mut Vec<Arc<Mutex<dyn BusResumeDevice>>>,
         #[cfg(feature = "swap")] swap_controller: &mut Option<swap::SwapController>,
-        #[cfg(unix)] ac_adapter: bool,
-        #[cfg(unix)] guest_suspended_cvar: Option<Arc<(Mutex<bool>, Condvar)>>,
+        #[cfg(any(target_os = "android", target_os = "linux"))] ac_adapter: bool,
+        #[cfg(any(target_os = "android", target_os = "linux"))] guest_suspended_cvar: Option<
+            Arc<(Mutex<bool>, Condvar)>,
+        >,
         pci_irqs: &[(PciAddress, u32, PciInterruptPin)],
     ) -> Result<(acpi::AcpiDevResource, Option<BatControl>)> {
         // The AML data for the acpi devices
@@ -1879,7 +1883,7 @@
 
         let bat_control = if let Some(battery_type) = battery.0 {
             match battery_type {
-                #[cfg(unix)]
+                #[cfg(any(target_os = "android", target_os = "linux"))]
                 BatteryType::Goldfish => {
                     let irq_num = resources.allocate_irq().ok_or(Error::CreateBatDevices(
                         arch::DeviceRegistrationError::AllocateIrq,
@@ -1928,7 +1932,7 @@
 
         let pm_sci_evt = devices::IrqLevelEvent::new().map_err(Error::CreateEvent)?;
 
-        #[cfg(unix)]
+        #[cfg(any(target_os = "android", target_os = "linux"))]
         let acdc = if ac_adapter {
             // Allocate GPE for AC adapter notfication
             let gpe = resources.allocate_gpe().ok_or(Error::AllocateGpe)?;
@@ -1961,7 +1965,7 @@
         let acdc = None;
 
         //Virtual PMC
-        #[cfg(unix)]
+        #[cfg(any(target_os = "android", target_os = "linux"))]
         if let Some(guest_suspended_cvar) = guest_suspended_cvar {
             let alloc = resources.get_anon_alloc();
             let mmio_base = resources
@@ -2182,7 +2186,7 @@
                 .map_err(Error::CreateDebugconDevice)?;
 
             let con: Arc<Mutex<dyn BusDevice>> = match debugcon_jail.as_ref() {
-                #[cfg(unix)]
+                #[cfg(any(target_os = "android", target_os = "linux"))]
                 Some(jail) => {
                     let jail_clone = jail.try_clone().map_err(Error::CloneJail)?;
                     #[cfg(feature = "seccomp_trace")]
diff --git a/x86_64/tests/integration/main.rs b/x86_64/tests/integration/main.rs
index a91d32d..3bf4194 100644
--- a/x86_64/tests/integration/main.rs
+++ b/x86_64/tests/integration/main.rs
@@ -215,7 +215,7 @@
         &mut resume_notify_devices,
         #[cfg(feature = "swap")]
         &mut None,
-        #[cfg(unix)]
+        #[cfg(any(target_os = "android", target_os = "linux"))]
         false,
         Default::default(),
         &pci_irqs,
diff --git a/x86_64/tests/integration/sys.rs b/x86_64/tests/integration/sys.rs
index 29cd03d..d91aa89 100644
--- a/x86_64/tests/integration/sys.rs
+++ b/x86_64/tests/integration/sys.rs
@@ -3,7 +3,7 @@
 // found in the LICENSE file.
 
 cfg_if::cfg_if! {
-    if #[cfg(unix)] {
+    if #[cfg(any(target_os = "android", target_os = "linux"))] {
         mod unix;
     }
 }