From f33a83d8577e08c73d3045da9b916ed42ed68ffb Mon Sep 17 00:00:00 2001 From: 500-internal-server-error <76838083+500-internal-server-error@users.noreply.github.com> Date: Wed, 12 Nov 2025 15:46:48 +0700 Subject: [PATCH 1/2] Fix test for cygwin --- src/unix/mod.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/unix/mod.rs b/src/unix/mod.rs index c3c65d0864838..f2589a1849c4d 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -402,6 +402,7 @@ cfg_if! { target_os = "android", target_os = "openbsd", target_os = "netbsd", + target_os = "cygwin", ))] { pub const FNM_NOESCAPE: c_int = 1 << 0; } else if #[cfg(target_os = "nto")] { From a8b347f860b5cb5c717ee0bd0f7c0f3f03284d4f Mon Sep 17 00:00:00 2001 From: 500-internal-server-error <76838083+500-internal-server-error@users.noreply.github.com> Date: Mon, 24 Nov 2025 21:11:41 +0700 Subject: [PATCH 2/2] cygwin: Add missing utmp/x.h, grp.h, and stdio.h interfaces These constants and functions are required for building uutils-coreutils for Cygwin. Sources: https://github.com/msys2/msys2-runtime/blob/msys2-3.6.5/winsup/cygwin/include/cygwin/config.h#L50 https://github.com/msys2/msys2-runtime/blob/msys2-3.6.5/newlib/libc/include/stdio.h#L138-L139 https://github.com/msys2/msys2-runtime/blob/msys2-3.6.5/winsup/cygwin/include/cygwin/utmp.h#L20-L33 https://github.com/msys2/msys2-runtime/blob/msys2-3.6.5/winsup/cygwin/include/utmpx.h#L21-L32 https://github.com/msys2/msys2-runtime/blob/msys2-3.6.5/newlib/libc/include/stdio.h#L120-L122 https://github.com/msys2/msys2-runtime/blob/msys2-3.6.5/newlib/libc/include/grp.h#L64-L65 https://github.com/msys2/msys2-runtime/blob/msys2-3.6.5/winsup/cygwin/include/utmpx.h#L21-L32 https://github.com/msys2/msys2-runtime/blob/msys2-3.6.5/winsup/cygwin/include/utmpx.h#L42-L49 --- libc-test/build.rs | 2 ++ src/unix/cygwin/mod.rs | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/libc-test/build.rs b/libc-test/build.rs index 7e7d28c1d19a0..0a91b6259d118 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -592,6 +592,7 @@ fn test_cygwin(target: &str) { "spawn.h", "stddef.h", "stdlib.h", + "stdio.h", "string.h", "sys/cpuset.h", "sys/ioctl.h", @@ -614,6 +615,7 @@ fn test_cygwin(target: &str) { "termios.h", "unistd.h", "utime.h", + "utmpx.h", "wait.h", "wchar.h", ); diff --git a/src/unix/cygwin/mod.rs b/src/unix/cygwin/mod.rs index 6dee1217953cc..4809d46ef4d1f 100644 --- a/src/unix/cygwin/mod.rs +++ b/src/unix/cygwin/mod.rs @@ -509,6 +509,18 @@ s_no_extra_traits! { pub ifc_len: c_int, pub ifc_ifcu: __c_anonymous_ifc_ifcu, } + + pub struct utmpx { + pub ut_type: c_short, + pub ut_pid: pid_t, + pub ut_line: [c_char; UT_LINESIZE], + pub ut_id: [c_char; UT_IDLEN], + pub ut_time: time_t, + pub ut_user: [c_char; UT_NAMESIZE], + pub ut_host: [c_char; UT_HOSTSIZE], + pub ut_addr: c_long, + pub ut_tv: timeval, + } } impl siginfo_t { @@ -889,6 +901,8 @@ pub const PATH_MAX: c_int = 4096; pub const PIPE_BUF: usize = 4096; pub const NGROUPS_MAX: c_int = 1024; +pub const FILENAME_MAX: c_int = 4096; + pub const FORK_RELOAD: c_int = 1; pub const FORK_NO_RELOAD: c_int = 0; @@ -966,6 +980,19 @@ pub const EAI_SOCKTYPE: c_int = 10; pub const EAI_SYSTEM: c_int = 11; pub const EAI_OVERFLOW: c_int = 14; +pub const UT_LINESIZE: usize = 16; +pub const UT_NAMESIZE: usize = 16; +pub const UT_HOSTSIZE: usize = 256; +pub const UT_IDLEN: usize = 2; +pub const RUN_LVL: c_short = 1; +pub const BOOT_TIME: c_short = 2; +pub const NEW_TIME: c_short = 3; +pub const OLD_TIME: c_short = 4; +pub const INIT_PROCESS: c_short = 5; +pub const LOGIN_PROCESS: c_short = 6; +pub const USER_PROCESS: c_short = 7; +pub const DEAD_PROCESS: c_short = 8; + pub const POLLIN: c_short = 0x1; pub const POLLPRI: c_short = 0x2; pub const POLLOUT: c_short = 0x4; @@ -1617,6 +1644,8 @@ pub const _POSIX_VDISABLE: cc_t = 0; pub const GRND_NONBLOCK: c_uint = 0x1; pub const GRND_RANDOM: c_uint = 0x2; +pub const _IOFBF: c_int = 0; +pub const _IOLBF: c_int = 1; pub const _IONBF: c_int = 2; pub const BUFSIZ: c_int = 1024; @@ -2317,6 +2346,7 @@ extern "C" { winp: *const crate::winsize, ) -> c_int; + pub fn getgrgid(gid: crate::gid_t) -> *mut crate::group; pub fn getgrgid_r( gid: crate::gid_t, grp: *mut crate::group, @@ -2330,6 +2360,7 @@ extern "C" { groups: *mut crate::gid_t, ngroups: *mut c_int, ) -> c_int; + pub fn getgrnam(name: *const c_char) -> *mut crate::group; pub fn getgrnam_r( name: *const c_char, grp: *mut crate::group, @@ -2345,4 +2376,13 @@ extern "C" { pub fn posix_fadvise(fd: c_int, offset: off_t, len: off_t, advise: c_int) -> c_int; pub fn posix_fallocate(fd: c_int, offset: off_t, len: off_t) -> c_int; pub fn fallocate(fd: c_int, mode: c_int, offset: off_t, len: off_t) -> c_int; + + pub fn endutxent(); + pub fn getutxent() -> *mut utmpx; + pub fn getutxid(id: *const utmpx) -> *mut utmpx; + pub fn getutxline(line: *const utmpx) -> *mut utmpx; + pub fn pututxline(utmpx: *const utmpx) -> *mut utmpx; + pub fn setutxent(); + pub fn utmpxname(file: *const c_char) -> c_int; + pub fn updwtmpx(file: *const c_char, utmpx: *const utmpx); }