summaryrefslogtreecommitdiff
path: root/win32/win32.c
AgeCommit message (Collapse)Author
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
2022-09-08[Bug #5317] Use `rb_off_t` instead of `off_t`Nobuyoshi Nakada
Get rid of the conflict with system-provided small `off_t`. Notes: Merged: https://github.com/ruby/ruby/pull/6329
2022-08-06Adjust styles [ci skip]Nobuyoshi Nakada
2022-07-21Expand tabs [ci skip]Takashi Kokubun
[Misc #18891] Notes: Merged: https://github.com/ruby/ruby/pull/6094
2022-07-19Rename ENCINDEX_ASCII to ENCINDEX_ASCII_8BITJean Boussier
Otherwise it's way too easy to confuse it with US_ASCII. Notes: Merged: https://github.com/ruby/ruby/pull/6127
2022-04-21[Win32] allow pipe in flockNobuyoshi Nakada
2022-04-15[Win32] Fix mode of character/pipe device stat [Bug #18732]Nobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/5803
2022-04-07Get rid of type-punning pointer castsNobuyoshi Nakada
2022-03-16Avoid console input behavior in windows 10 [Bug #18588]YO4
When ANSI versions of PeekConsoleInput read multibyte charactor partially, subsequent ReadFile returns wrong data on newer Windows 10 versions (probably since Windows Terminal introduced). To avoid this, use Unicode version of of PeekConsoleInput/ReadConsole. Notes: Merged: https://github.com/ruby/ruby/pull/5634 Merged-By: nobu <nobu@ruby-lang.org>
2022-01-18include/ruby/win32.h: define HAVE_X for the missing prototypes (#5456)Yuta Saito
Notes: Merged-By: kateinoigakukun
2021-12-30win32/win32.c Fix PROT_EXEC bit flag check for FlushInstrucitonCache()nagachika
Notes: Merged: https://github.com/ruby/ruby/pull/5372
2021-12-27Fix some bornheadsU.Nakamura
2021-12-27Tiny mmap emulation for WindowsU.Nakamura
- prerequisite of supporting YJIT with VC++. - note that now can specfily `--yjit` on mswin64, but not enabled YJIT'ed code because of YJIT requires `OPT_DIRECT_THREADED_CODE` or `OPT_CALL_THREADED_CODE` in `rb_yjit_compile_iseq`.
2021-10-04Clang never evaluates expr in `__builtin_assume`xtkoba
Notes: Merged: https://github.com/ruby/ruby/pull/4446
2021-09-24Reminders of the Windows versions each API is available [ci skip]Nobuyoshi Nakada
2021-09-20MINGW: _WIN64 is not defined on i386-mingw32 + ucrt.xtkoba (Tee KOBAYASHI)
Notes: Merged: https://github.com/ruby/ruby/pull/4599
2021-09-20MINGW: Fix build error on Windows UCRTxtkoba (Tee KOBAYASHI)
Notes: Merged: https://github.com/ruby/ruby/pull/4599
2021-06-23Add parentheses to avoid pointless conditionJeremy Evans
Pointed out by xtkoba (Tee KOBAYASHI). Fixes [Bug #17946] Notes: Merged: https://github.com/ruby/ruby/pull/4575
2021-05-04`_MSC_VER` may not be definedxtkoba
Notes: Merged: https://github.com/ruby/ruby/pull/4453
2021-03-08Increment global variables atomicallyNobuyoshi Nakada
2021-03-08Make vm_exit_handler installation MT-safeNobuyoshi Nakada
2021-03-08Make uenvarea thread exclusiveNobuyoshi Nakada
2021-03-08Make the flag in thread_exclusive uniqueNobuyoshi Nakada
2021-03-08Enclose crtitical sections in `thread_exclusive` blockNobuyoshi Nakada
2021-02-24Revert "Enclose crtitical sections in `thread_exclusive` block"Nobuyoshi Nakada
19cc24b34b0490b7c2779eec521fe0089e05f183 and fixups.
2021-02-23Use the system getenv in setup_debug_logNobuyoshi Nakada
As ruby_set_debug_option() is called before ruby_sysinit(), CRITICAL_SECTIONs are not initialized yet.
2021-02-23Fixed commit miss at 41eb4fbf86e7ae9c9ff993e07a19fa44eb74be9bNobuyoshi Nakada
2021-02-23Make uenvarea thread exclusiveNobuyoshi Nakada
2021-02-23Fixed commit miss at 19cc24b34b0490b7c2779eec521fe0089e05f183Nobuyoshi Nakada
2021-02-23Constified possible dataNobuyoshi Nakada