From 224bb40844b1f5dfe6b698ee699bb4ee60683fec Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Fri, 25 Sep 2026 16:27:08 +0900 Subject: [PATCH] Remove Windows redefinitions that duplicate win32.h include/ruby/win32.h already maps stat, lstat, access, truncate, utimensat, unlink, rename and getenv to the same rb_w32_* functions when compiling the core with RUBY_EXPORT. Co-Authored-By: Claude Opus 5.5 --- file.c | 16 +--------------- hash.c | 2 -- 2 files changed, 1 insertion(+), 17 deletions(-) diff --git a/file.c b/file.c index 51e68dcade6..833c63e965d 100644 --- a/file.c +++ b/file.c @@ -95,29 +95,16 @@ int flock(int, int); /* define system APIs */ #ifdef _WIN32 # include "win32/file.h" -# define STAT(p, s) rb_w32_ustati128((p), (s)) -# undef lstat -# define lstat(p, s) rb_w32_ulstati128((p), (s)) -# undef access -# define access(p, m) rb_w32_uaccess((p), (m)) -# undef truncate -# define truncate(p, n) rb_w32_utruncate((p), (n)) # undef chmod # define chmod(p, m) rb_w32_uchmod((p), (m)) # undef chown # define chown(p, o, g) rb_w32_uchown((p), (o), (g)) # undef lchown # define lchown(p, o, g) rb_w32_ulchown((p), (o), (g)) -# undef utimensat -# define utimensat(s, p, t, f) rb_w32_uutimensat((s), (p), (t), (f)) # undef link # define link(f, t) rb_w32_ulink((f), (t)) -# undef unlink -# define unlink(p) rb_w32_uunlink(p) # undef readlink # define readlink(f, t, l) rb_w32_ureadlink((f), (t), (l)) -# undef rename -# define rename(f, t) rb_w32_urename((f), (t)) # undef symlink # define symlink(s, l) rb_w32_usymlink((s), (l)) @@ -126,9 +113,8 @@ int flock(int, int); absolute paths does not work for drive letters. */ # undef HAVE_REALPATH # endif -#else -# define STAT(p, s) stat((p), (s)) #endif /* _WIN32 */ +#define STAT(p, s) stat((p), (s)) #ifdef HAVE_STRUCT_STATX_STX_BTIME # define ST_(name) stx_ ## name diff --git a/hash.c b/hash.c index cec50e0ad52..a980d05baa2 100644 --- a/hash.c +++ b/hash.c @@ -5457,8 +5457,6 @@ static char **origenviron; static char **my_environ; #undef environ #define environ my_environ -#undef getenv -#define getenv(n) rb_w32_ugetenv(n) #elif defined(__APPLE__) #undef environ #define environ (*_NSGetEnviron())