1From f4d0faa256057dc56647ff734069bdffa52e487a Mon Sep 17 00:00:00 2001 2From: Marcin Radomski <marcin@mradomski.pl> 3Date: Wed, 20 Mar 2024 16:56:28 +0000 4Subject: [PATCH] Don't rename errno to libc_errno 5 6See b/331344966 for status of the efforts to upstream this. 7 8Change-Id: Ied4890f9a6217c627624daa33d98b1bb78081bba 9--- 10 Cargo.toml | 16 ++++++---------- 11 Cargo.toml.orig | 13 ++++++------- 12 src/backend/libc/event/syscalls.rs | 2 ++ 13 src/backend/libc/fs/dir.rs | 2 +- 14 src/backend/libc/fs/syscalls.rs | 2 ++ 15 src/backend/libc/io/errno.rs | 2 +- 16 src/backend/libc/io/syscalls.rs | 2 +- 17 src/backend/libc/process/syscalls.rs | 2 ++ 18 src/backend/libc/pty/syscalls.rs | 2 ++ 19 src/weak.rs | 2 ++ 20 10 files changed, 25 insertions(+), 20 deletions(-) 21 22diff --git a/Cargo.toml b/Cargo.toml 23index 8f091a9a..19269d40 100644 24--- a/Cargo.toml 25+++ b/Cargo.toml 26@@ -101,10 +101,9 @@ version = "1.0" 27 [dev-dependencies.libc] 28 version = "0.2.152" 29 30-[dev-dependencies.libc_errno] 31+[dev-dependencies.errno] 32 version = "0.3.8" 33 default-features = false 34-package = "errno" 35 36 [dev-dependencies.memoffset] 37 version = "0.9.0" 38@@ -191,7 +190,7 @@ std = [ 39 "bitflags/std", 40 "alloc", 41 "libc?/std", 42- "libc_errno?/std", 43+ "errno?/std", 44 ] 45 stdio = [] 46 system = ["linux-raw-sys/system"] 47@@ -200,7 +199,7 @@ thread = ["linux-raw-sys/prctl"] 48 time = [] 49 use-explicitly-provided-auxv = [] 50 use-libc = [ 51- "libc_errno", 52+ "errno", 53 "libc", 54 ] 55 use-libc-auxv = [] 56@@ -224,11 +223,10 @@ features = ["extra_traits"] 57 optional = true 58 default-features = false 59 60-[target."cfg(all(not(rustix_use_libc), not(miri), target_os = \"linux\", target_endian = \"little\", any(target_arch = \"arm\", all(target_arch = \"aarch64\", target_pointer_width = \"64\"), target_arch = \"riscv64\", all(rustix_use_experimental_asm, target_arch = \"powerpc64\"), all(rustix_use_experimental_asm, target_arch = \"mips\"), all(rustix_use_experimental_asm, target_arch = \"mips32r6\"), all(rustix_use_experimental_asm, target_arch = \"mips64\"), all(rustix_use_experimental_asm, target_arch = \"mips64r6\"), target_arch = \"x86\", all(target_arch = \"x86_64\", target_pointer_width = \"64\"))))".dependencies.libc_errno] 61+[target."cfg(all(not(rustix_use_libc), not(miri), target_os = \"linux\", target_endian = \"little\", any(target_arch = \"arm\", all(target_arch = \"aarch64\", target_pointer_width = \"64\"), target_arch = \"riscv64\", all(rustix_use_experimental_asm, target_arch = \"powerpc64\"), all(rustix_use_experimental_asm, target_arch = \"mips\"), all(rustix_use_experimental_asm, target_arch = \"mips32r6\"), all(rustix_use_experimental_asm, target_arch = \"mips64\"), all(rustix_use_experimental_asm, target_arch = \"mips64r6\"), target_arch = \"x86\", all(target_arch = \"x86_64\", target_pointer_width = \"64\"))))".dependencies.errno] 62 version = "0.3.8" 63 optional = true 64 default-features = false 65-package = "errno" 66 67 [target."cfg(all(not(rustix_use_libc), not(miri), target_os = \"linux\", target_endian = \"little\", any(target_arch = \"arm\", all(target_arch = \"aarch64\", target_pointer_width = \"64\"), target_arch = \"riscv64\", all(rustix_use_experimental_asm, target_arch = \"powerpc64\"), all(rustix_use_experimental_asm, target_arch = \"mips\"), all(rustix_use_experimental_asm, target_arch = \"mips32r6\"), all(rustix_use_experimental_asm, target_arch = \"mips64\"), all(rustix_use_experimental_asm, target_arch = \"mips64r6\"), target_arch = \"x86\", all(target_arch = \"x86_64\", target_pointer_width = \"64\"))))".dependencies.linux-raw-sys] 68 version = "0.4.12" 69@@ -247,19 +245,17 @@ version = "0.2.152" 70 features = ["extra_traits"] 71 default-features = false 72 73-[target."cfg(all(not(windows), any(rustix_use_libc, miri, not(all(target_os = \"linux\", target_endian = \"little\", any(target_arch = \"arm\", all(target_arch = \"aarch64\", target_pointer_width = \"64\"), target_arch = \"riscv64\", all(rustix_use_experimental_asm, target_arch = \"powerpc64\"), all(rustix_use_experimental_asm, target_arch = \"mips\"), all(rustix_use_experimental_asm, target_arch = \"mips32r6\"), all(rustix_use_experimental_asm, target_arch = \"mips64\"), all(rustix_use_experimental_asm, target_arch = \"mips64r6\"), target_arch = \"x86\", all(target_arch = \"x86_64\", target_pointer_width = \"64\")))))))".dependencies.libc_errno] 74+[target."cfg(all(not(windows), any(rustix_use_libc, miri, not(all(target_os = \"linux\", target_endian = \"little\", any(target_arch = \"arm\", all(target_arch = \"aarch64\", target_pointer_width = \"64\"), target_arch = \"riscv64\", all(rustix_use_experimental_asm, target_arch = \"powerpc64\"), all(rustix_use_experimental_asm, target_arch = \"mips\"), all(rustix_use_experimental_asm, target_arch = \"mips32r6\"), all(rustix_use_experimental_asm, target_arch = \"mips64\"), all(rustix_use_experimental_asm, target_arch = \"mips64r6\"), target_arch = \"x86\", all(target_arch = \"x86_64\", target_pointer_width = \"64\")))))))".dependencies.errno] 75 version = "0.3.8" 76 default-features = false 77-package = "errno" 78 79 [target."cfg(any(target_os = \"android\", target_os = \"linux\"))".dependencies.once_cell] 80 version = "1.5.2" 81 optional = true 82 83-[target."cfg(windows)".dependencies.libc_errno] 84+[target."cfg(windows)".dependencies.errno] 85 version = "0.3.8" 86 default-features = false 87-package = "errno" 88 89 [target."cfg(windows)".dependencies.windows-sys] 90 version = "0.52.0" 91diff --git a/Cargo.toml.orig b/Cargo.toml.orig 92index ffde0dba..4592ae97 100644 93--- a/Cargo.toml.orig 94+++ b/Cargo.toml.orig 95@@ -38,7 +38,7 @@ once_cell = { version = "1.5.2", optional = true } 96 # Enabling only the libc backend will limit available functionality. 97 [target.'cfg(all(not(rustix_use_libc), not(miri), target_os = "linux", target_endian = "little", any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "mips"), all(rustix_use_experimental_asm, target_arch = "mips32r6"), all(rustix_use_experimental_asm, target_arch = "mips64"), all(rustix_use_experimental_asm, target_arch = "mips64r6"), target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64"))))'.dependencies] 98 linux-raw-sys = { version = "0.4.12", default-features = false, features = ["general", "errno", "ioctl", "no_std", "elf"], optional = true } 99-libc_errno = { package = "errno", version = "0.3.8", default-features = false, optional = true } 100+errno = { version = "0.3.8", default-features = false, optional = true } 101 libc = { version = "0.2.152", default-features = false, features = ["extra_traits"], optional = true } 102 103 # Dependencies for platforms where only libc is supported: 104@@ -46,7 +46,7 @@ libc = { version = "0.2.152", default-features = false, features = ["extra_trait 105 # On all other Unix-family platforms, and under Miri, we always use the libc 106 # backend, so enable its dependencies unconditionally. 107 [target.'cfg(all(not(windows), any(rustix_use_libc, miri, not(all(target_os = "linux", target_endian = "little", any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "mips"), all(rustix_use_experimental_asm, target_arch = "mips32r6"), all(rustix_use_experimental_asm, target_arch = "mips64"), all(rustix_use_experimental_asm, target_arch = "mips64r6"), target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64")))))))'.dependencies] 108-libc_errno = { package = "errno", version = "0.3.8", default-features = false } 109+errno = { version = "0.3.8", default-features = false } 110 libc = { version = "0.2.152", default-features = false, features = ["extra_traits"] } 111 112 # Additional dependencies for Linux with the libc backend: 113@@ -68,15 +68,14 @@ features = [ 114 115 # For the libc backend on Windows, also use the errno crate, which has Windows 116 # support. 117-[target.'cfg(windows)'.dependencies.libc_errno] 118+[target.'cfg(windows)'.dependencies.errno] 119 version = "0.3.8" 120-package = "errno" 121 default-features = false 122 123 [dev-dependencies] 124 tempfile = "3.5.0" 125 libc = "0.2.152" 126-libc_errno = { package = "errno", version = "0.3.8", default-features = false } 127+errno = { version = "0.3.8", default-features = false } 128 serial_test = "2.0.0" 129 memoffset = "0.9.0" 130 flate2 = "1.0" 131@@ -124,10 +123,10 @@ default = ["std", "use-libc-auxv"] 132 133 # This enables use of std. Disabling this enables `#![no_std]`, and requires 134 # Rust 1.64 or newer. 135-std = ["bitflags/std", "alloc", "libc?/std", "libc_errno?/std"] 136+std = ["bitflags/std", "alloc", "libc?/std", "errno?/std"] 137 138 # Enable this to request the libc backend. 139-use-libc = ["libc_errno", "libc"] 140+use-libc = ["errno", "libc"] 141 142 # Enable `rustix::event::*`. 143 event = [] 144diff --git a/src/backend/libc/event/syscalls.rs b/src/backend/libc/event/syscalls.rs 145index 725ec825..c3c5245e 100644 146--- a/src/backend/libc/event/syscalls.rs 147+++ b/src/backend/libc/event/syscalls.rs 148@@ -25,6 +25,8 @@ use {crate::backend::conv::ret_owned_fd, crate::event::EventfdFlags}; 149 #[cfg(all(feature = "alloc", bsd))] 150 use {crate::event::kqueue::Event, crate::utils::as_ptr, core::ptr::null}; 151 152+use errno as libc_errno; 153+ 154 #[cfg(any( 155 linux_kernel, 156 target_os = "freebsd", 157diff --git a/src/backend/libc/fs/dir.rs b/src/backend/libc/fs/dir.rs 158index 6c827432..e3d4dfd1 100644 159--- a/src/backend/libc/fs/dir.rs 160+++ b/src/backend/libc/fs/dir.rs 161@@ -36,7 +36,7 @@ use c::readdir as libc_readdir; 162 use c::readdir64 as libc_readdir; 163 use core::fmt; 164 use core::ptr::NonNull; 165-use libc_errno::{errno, set_errno, Errno}; 166+use errno::{errno, set_errno, Errno}; 167 168 /// `DIR*` 169 pub struct Dir { 170diff --git a/src/backend/libc/fs/syscalls.rs b/src/backend/libc/fs/syscalls.rs 171index 446601ac..4b3bff1d 100644 172--- a/src/backend/libc/fs/syscalls.rs 173+++ b/src/backend/libc/fs/syscalls.rs 174@@ -89,6 +89,8 @@ use { 175 core::ptr::null, 176 }; 177 178+use errno as libc_errno; 179+ 180 #[cfg(all(target_env = "gnu", fix_y2038))] 181 weak!(fn __utimensat64(c::c_int, *const c::c_char, *const LibcTimespec, c::c_int) -> c::c_int); 182 #[cfg(all(target_env = "gnu", fix_y2038))] 183diff --git a/src/backend/libc/io/errno.rs b/src/backend/libc/io/errno.rs 184index 805ea679..8d3d00ac 100644 185--- a/src/backend/libc/io/errno.rs 186+++ b/src/backend/libc/io/errno.rs 187@@ -4,7 +4,7 @@ 188 //! `errno` value. 189 190 use crate::backend::c; 191-use libc_errno::errno; 192+use errno::errno; 193 194 /// `errno`—An error code. 195 /// 196diff --git a/src/backend/libc/io/syscalls.rs b/src/backend/libc/io/syscalls.rs 197index da88f54b..1a5e1fbd 100644 198--- a/src/backend/libc/io/syscalls.rs 199+++ b/src/backend/libc/io/syscalls.rs 200@@ -19,7 +19,7 @@ use crate::io::{self, FdFlags}; 201 use crate::ioctl::{IoctlOutput, RawOpcode}; 202 use core::cmp::min; 203 #[cfg(all(feature = "fs", feature = "net"))] 204-use libc_errno::errno; 205+use errno::errno; 206 #[cfg(not(target_os = "espidf"))] 207 use { 208 crate::backend::MAX_IOV, 209diff --git a/src/backend/libc/process/syscalls.rs b/src/backend/libc/process/syscalls.rs 210index 46fd1821..8d931b95 100644 211--- a/src/backend/libc/process/syscalls.rs 212+++ b/src/backend/libc/process/syscalls.rs 213@@ -72,6 +72,8 @@ use { 214 super::super::conv::ret_owned_fd, crate::process::PidfdFlags, crate::process::PidfdGetfdFlags, 215 }; 216 217+use errno as libc_errno; 218+ 219 #[cfg(any(linux_kernel, target_os = "dragonfly"))] 220 #[inline] 221 pub(crate) fn sched_getcpu() -> usize { 222diff --git a/src/backend/libc/pty/syscalls.rs b/src/backend/libc/pty/syscalls.rs 223index 2395efde..85d2255b 100644 224--- a/src/backend/libc/pty/syscalls.rs 225+++ b/src/backend/libc/pty/syscalls.rs 226@@ -18,6 +18,8 @@ use { 227 #[cfg(not(linux_kernel))] 228 use crate::{backend::conv::ret_owned_fd, fd::OwnedFd, pty::OpenptFlags}; 229 230+use errno as libc_errno; 231+ 232 #[cfg(not(linux_kernel))] 233 #[inline] 234 pub(crate) fn openpt(flags: OpenptFlags) -> io::Result<OwnedFd> { 235diff --git a/src/weak.rs b/src/weak.rs 236index 3cda8e6c..56be05ce 100644 237--- a/src/weak.rs 238+++ b/src/weak.rs 239@@ -38,6 +38,8 @@ use core::ptr::null_mut; 240 use core::sync::atomic::{self, AtomicPtr, Ordering}; 241 use core::{marker, mem}; 242 243+use errno as libc_errno; 244+ 245 const NULL: *mut c_void = null_mut(); 246 const INVALID: *mut c_void = 1 as *mut c_void; 247 248-- 2492.44.0.396.g6e790dbe36-goog 250 251