summaryrefslogtreecommitdiff
path: root/win32/win32.c
AgeCommit message (Collapse)Author
2025-12-24Win32: Remove an unused functionNobuyoshi Nakada
Since 50e5c542cc0541fb38e52766d88d87bd8a96b072, `constat_reset` is no longer used.
2025-12-12Win32: Make `rb_w32_osid` return Windows NT alwaysNobuyoshi Nakada
Since support for Windows 9x was dropped over a decade ago.
2025-12-12Win32: Remove the workaround for console reading bugNobuyoshi Nakada
It has been fixed at Windows 8, and we already have dropped the support Windows 8 and olders.
2025-11-19Win32: Drop support for older than MSVC 14.0/_MSC_VER 1900Nobuyoshi Nakada
Visual C++ 2015 (14.0): - _MSC_VER: 1900 - MSVCRT_VERSION: 140
2025-11-19Win32: Drop support for older than MSVC 12.0/_MSC_VER 1800Nobuyoshi Nakada
Visual C++ 2013 (12.0): - _MSC_VER: 1800 - MSVCRT_VERSION: 120
2025-11-19Win32: Drop support for older than MSVC 10.0/_MSC_VER 1600Nobuyoshi Nakada
Visual C++ 2010 (10.0): - _MSC_VER: 1600 - MSVCRT_VERSION: 100
2025-11-19Win32: Drop support for older than MSVC 9.0/_MSC_VER 1500Nobuyoshi Nakada
Visual C++ 2008 (9.0): - _MSC_VER: 1500 - MSVCRT_VERSION: 90
2025-11-19Win32: Drop support for older than MSVC 8.0/_MSC_VER 1400Nobuyoshi Nakada
Visual C++ 2005 (8.0): - _MSC_VER: 1400 - MSVCRT_VERSION: 80
2025-10-29win32: Extract `FILETIME` related constants.Nobuyoshi Nakada
2025-10-29win32: Optimize `FIMETIME` calculationsNobuyoshi Nakada
Assume that `FILETIME` and `ULARGE_INTEGER::u` are the same layout actually.
2025-10-17win32: Prefix `clock_getclock` and `clock_getres`Nobuyoshi Nakada
Get rid of conflict with inline versions provided in time.h.
2025-10-17win32: Fix missing typeNobuyoshi Nakada
2025-10-17win32: Support more `clockid_t`Nobuyoshi Nakada
Add `CLOCK_PROCESS_CPUTIME_ID` and `CLOCK_THREAD_CPUTIME_ID`.
2025-10-05Win32: Fix fallback parsing of CSI SGR sequencesNobuyoshi Nakada
2025-05-22Fix for old mingw without `clock_gettime` and `clock_getres`Nobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/13405
2025-05-12Fix redefinition of `clock_gettime` and `clock_getres`Nobuyoshi Nakada
winpthreads-git 12.0.0.r720 provides `clock_gettime` and `clock_getres` as inline functions. Notes: Merged: https://github.com/ruby/ruby/pull/13302
2025-05-11Revert "Fix redefinition of `clock_gettime` and `clock_getres`"Hiroshi SHIBATA
This reverts commit 585598623da949c92d0f2ea94029a863142ec908. This broke Windows CIs ``` linking miniruby.exe Creating library miniruby.lib and object miniruby.exp process.obj : error LNK2019: unresolved external symbol clock_gettime referenced in function rb_clock_gettime random.obj : error LNK2001: unresolved external symbol clock_gettime thread.obj : error LNK2001: unresolved external symbol clock_gettime time.obj : error LNK2001: unresolved external symbol clock_gettime process.obj : error LNK2019: unresolved external symbol clock_getres referenced in function rb_clock_getres miniruby.exe : fatal error LNK1120: 2 unresolved externals NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.29.30133\bin\HostX64\x64\cl.EXE"' : return code '0x2' ``` Notes: Merged: https://github.com/ruby/ruby/pull/13300
2025-05-10Fix redefinition of `clock_gettime` and `clock_getres`Nobuyoshi Nakada
winpthreads-git 12.0.0.r720 provides `clock_gettime` and `clock_getres` as inline functions.
2025-03-19fix rb_w32_strerror when errno < 0YO4
change SystemCallError.new(-1) message on Windows (Bug #21083) https://bugs.ruby-lang.org/issues/21083 Notes: Merged: https://github.com/ruby/ruby/pull/12622
2025-03-12[Bug #21177] Win32: Allow longer path nameNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/12901
2025-02-13Remove a stale function for MJITNobuyoshi Nakada
2025-02-13Remove stale comment for MJITNobuyoshi Nakada
2024-11-30[win32] fix arm64 instruction decodingjeremyd2019
Two minor fixes to arm64 instruction decoding when looking for __pioinfo: 1. add_mask was shifted by one bit, it was intended to be 0x7f800000. However, since the mask was already excluding matching the 'sh' bit, and since the purpose of the add following the adrp is to add in the lower 12 bits, I opted to set the mask to 0x7fc00000 and simply remove the handling for the 12 bit shift option which is now required to be disabled in order to match. 2. adrp's immediate was supposed to be sign extended. So far, I have not seen cases where the global variable ends up before the code in memory, but it's a possibility, so handle the sign extension. Notes: Merged: https://github.com/ruby/ruby/pull/12222
2024-09-24Windows: Remove compatibility to ancient MSVCRT APILars Kanis
Using _wputenv_s simplifies the code and we can avoid code duplication by using rb_w32_home_dir() to initialize ENV['HOME']. Notes: Merged: https://github.com/ruby/ruby/pull/7034
2024-09-12Add error checking to readdir, telldir, and closedir calls in dir.cJeremy Evans
Raise SystemCallError exception when these functions return an error. This changes behavior for the following case (found by the tests): ```ruby dir1 = Dir.new('..') dir2 = Dir.for_fd(dir1.fileno) dir1.close dir2.close ``` The above code is basically broken, as `dir1.close` closed the file descriptor. The subsequent `dir2.close` call is undefined behavior. When run in isolation, it raises Errno::EBADF after the change, but if another thread opens a file descriptor between the `dir1.close` and `dir2.close` calls, the `dir2.close` call could close the file descriptor opened by the other thread. Raising an exception is much better in this case as it makes it obvious there is a bug in the code. For the readdir check, since the GVL has already been released, reacquire it rb_thread_call_with_gvl if an exception needs to be raised. Due to the number of closedir calls, this adds static close_dir_data and check_closedir functions. The close_dir_data takes a struct dir_data * and handles setting the dir entry to NULL regardless of failure. Fixes [Bug #20586] Co-authored-by: Nobuyoshi Nakada <nobu.nakada@gmail.com> Notes: Merged: https://github.com/ruby/ruby/pull/11393 Merged-By: jeremyevans <code@jeremyevans.net>
2024-08-11fix i386-ucrt buildRaed Rizqie
Notes: Merged: https://github.com/ruby/ruby/pull/11358
2024-07-31[Feature #20563] Drop support for Windows older than 8/Sever 2012Nobuyoshi Nakada
Directly call APIs available on Windows 8/Server 2012 and later. Notes: Merged: https://github.com/ruby/ruby/pull/11279
2024-07-31[Feature #20563] Drop support for Windows older than Vista/2008Nobuyoshi Nakada
Directly call APIs available on Windows Vista/Server 2008 and later. Notes: Merged: https://github.com/ruby/ruby/pull/11279
2024-05-29Fix `calloc` arguments order for -Wcalloc-transposed-argsNobuyoshi Nakada
2023-11-23windows-arm64 support (#8995)Pierrick Bouvier
* [win32] fix compilation for windows-arm64 Credits to MSYS2 Ruby package using this patch. * [win32] nm use full options Fix compilation error when using MSYS2 environment. Credits to MSYS2 Ruby package using this patch. * [win32] detect llvm-windres (used for windows-arm64) When adding preprocessor option for llvm-windres (using clang as parameter), it fails. Thus, do not add this. It's needed to be able to compile windows-arm64 version, because MSYS2 toolchain is LLVM based (instead of GCC/binutils). * [win32] pioinfo detection for windows-arm64 This fixes "unexpected ucrtbase.dll" for native windows-arm64 ruby binary. It does not solve issue with x64 version emulated on this platform. Value of pioinfo pointer can be found in ucrtbase.dll at latest adrp/add sequence before return of _isatty function. This works for both release and debug ucrt. Due to the nature of aarch64 ISA (vs x86 or x64), it's needed to disassemble instructions to retrieve offset value, which is a bit more complicated than matching specific string patterns. Details about adrp/add usage can be found in this blog post: https://devblogs.microsoft.com/oldnewthing/20220809-00/?p=106955 For instruction decoding, the Arm documentation was used as a reference.
2023-10-27[Feature #19244] Windows: Prefer USERPROFILE over HOMEPATH on startup as wellLars Kanis
2023-09-25Add `rb_w32_uspawn_process`Nobuyoshi Nakada
2023-06-30Don't check for null pointer in calls to freePeter Zhu
According to the C99 specification section 7.20.3.2 paragraph 2: > If ptr is a null pointer, no action occurs. So we do not need to check that the pointer is a null pointer. Notes: Merged: https://github.com/ruby/ruby/pull/8004
2023-06-01Hide the usage of `rb_io_t` where possible. (#7880)Samuel Williams
This retries the compatible parts of the previously reverted PR so we can continue to update related code without breaking backwards compatibility. Notes: Merged-By: ioquatix <samuel@codeotaku.com>
2023-06-01Revert "Hide most of the implementation of `struct rb_io`. (#6511)"NARUSE, Yui
This reverts commit 18e55fc1e1ec20e8f3166e3059e76c885fc9f8f2. fix [Bug #19704] https://bugs.ruby-lang.org/issues/19704 This breaks compatibility for extension libraries. Such changes need a discussion.
2023-05-30Hide most of the implementation of `struct rb_io`. (#6511)Samuel Williams
* Add rb_io_path and rb_io_open_descriptor. * Use rb_io_open_descriptor to create PTY objects * Rename FMODE_PREP -> FMODE_EXTERNAL and expose it FMODE_PREP I believe refers to the concept of a "pre-prepared" file, but FMODE_EXTERNAL is clearer about what the file descriptor represents and aligns with language in the IO::Buffer module. * Ensure that rb_io_open_descriptor closes the FD if it fails If FMODE_EXTERNAL is not set, then it's guaranteed that Ruby will be responsible for closing your file, eventually, if you pass it to rb_io_open_descriptor, even if it raises an exception. * Rename IS_EXTERNAL_FD -> RUBY_IO_EXTERNAL_P * Expose `rb_io_closed_p`. * Add `rb_io_mode` to get IO mode. --------- Co-authored-by: KJ Tsanaktsidis <ktsanaktsidis@zendesk.com> Notes: Merged-By: ioquatix <samuel@codeotaku.com>
2023-05-24Fix "runs a C function with the global lock unlocked and unlocks IO with the ↵Samuel Williams
generic RUBY_UBF_IO" on Windows. (#7848) * Enable borked spec. * Ensure win32 wrappers are visible and used. * Reorganise `read`/`write`/`pipe` in `thread_spec.c`. Notes: Merged-By: ioquatix <samuel@codeotaku.com>
2023-05-24Add support for pread/pwrite on windows. (#7827)Samuel Williams
Notes: Merged-By: ioquatix <samuel@codeotaku.com>
2023-03-06s/MJIT/RJIT/Takashi Kokubun
Notes: Merged: https://github.com/ruby/ruby/pull/7462
2023-03-06Stop exporting symbols for MJITTakashi Kokubun
Notes: Merged: https://github.com/ruby/ruby/pull/7459
2023-02-26Adjust `else` style to be consistent in each files [ci skip]Nobuyoshi Nakada
2022-12-24Windows: Prefer USERPROFILE over HOMEPATHLars Kanis
HOMEPATH is set to "\WINDOWS\system32" when running per "runas" session. This directory is not writable by ordinary users, leading to errors with many ruby tools. Also config files in the home directory are not recognized. Still keeping HOME at first which is not used by native Windows, but by ruby specs and by MSYS2 environment. Notes: Merged: https://github.com/ruby/ruby/pull/6992
2022-12-15Add more comments why CRuby uses __pioinfoNARUSE, Yui
2022-11-25Use `rb_sprintf` instead of deprecated `sprintf`Nobuyoshi Nakada
2022-11-20Avoid warnings on MINGW:Lars Kanis
win32/win32.c: In function 'rtc_error_handler': win32/win32.c:691:5: warning: function 'rtc_error_handler' might be a candidate for 'gnu_printf' format attribute [-Wsuggest-attribute=format] 691 | rb_str_vcatf(str, fmt, ap); | ^~~~~~~~~~~~ and win32/win32.c:683:1: warning: 'rtc_error_handler' defined but not used [-Wunused-function] 683 | rtc_error_handler(int e, const char *src, int line, const char *exe, const char *fmt, ...) | ^~~~~~~~~~~~~~~~~ Notes: Merged: https://github.com/ruby/ruby/pull/6764
2022-11-17Add support for `sockaddr_un` on Windows. (#6513)Samuel Williams
* Windows: Fix warning about undefined if_indextoname() * Windows: Fix UNIXSocket on MINGW and make .pair more reliable * Windows: Use nonblock=true for read tests with scheduler * Windows: Move socket detection from File.socket? to File.stat Add S_IFSOCK to Windows and interpret reparse points accordingly. Enable tests that work now. * Windows: Use wide-char functions to UNIXSocket This fixes behaviour with non-ASCII characters. It also fixes deletion of temporary UNIXSocket.pair files. * Windows: Add UNIXSocket tests for specifics of Windows impl. * Windows: fix VC build due to missing _snwprintf Avoid usage of _snwprintf, since it fails linking ruby.dll like so: linking shared-library x64-vcruntime140-ruby320.dll x64-vcruntime140-ruby320.def : error LNK2001: unresolved external symbol snwprintf x64-vcruntime140-ruby320.def : error LNK2001: unresolved external symbol vsnwprintf_l whereas linking miniruby.exe succeeds. This patch uses snprintf on the UTF-8 string instead. Also remove branch GetWindowsDirectoryW, since it doesn't work. * Windows: Fix dangling symlink test failures Co-authored-by: Lars Kanis <kanis@comcard.de> Notes: Merged-By: ioquatix <samuel@codeotaku.com>
2022-11-17Windows: Readlink improvements (#6745)Lars Kanis
* Windows: Use readlink emulation for File.readlink This fixes readlink emulation for the ERROR_MORE_DATA case and general error reporting. It now releases GVL while readlink IO operation. The dedicated rb_readlink was introduced in commit 2ffb87995a33cdc7ba609a4b867f03f18da0c3b3 in order to improve encoding and buffer allocation. However the encoding issues are solved since ruby-3.0 switched to UTF-8 and the buffer allocation will be improved in a later commit. * Windows: Increase the default buffer size for reparse point info So far nearly all queries of reparse points needed two attempts to get enough buffer. * Windows: Remove declaration of rb_w32_wreadlink It was removed in commit 2f6fdd3aebdee2ce04d003b206f6da78120e8235 Notes: Merged-By: ioquatix <samuel@codeotaku.com>
2022-09-09eliminate magic numberYO4
Notes: Merged: https://github.com/ruby/ruby/pull/6328
2022-09-09win32.c additional fix: is_readable_consoleYO4
classic console(conhost.exe) reports an input with ALT+NUMPAD as VK_MENU, KeyUp, and uChar!=0. additional fix for #5634 Notes: Merged: https://github.com/ruby/ruby/pull/6328
2022-09-09win32.c fix: is_readable_consoleYO4
UnicodeChar with lower byte == 0 has dropped accidentaly this is additional fix for #5634 Notes: Merged: https://github.com/ruby/ruby/pull/6328