Commit graph

763 commits

Author SHA1 Message Date
Lars Kanis
d0f5dc9eac Windows: Prefer USERPROFILE over HOMEPATH
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.
2022-12-24 23:48:47 +09:00
NARUSE, Yui
9eb19a02ae Add more comments why CRuby uses __pioinfo 2022-12-15 00:14:00 +09:00
Nobuyoshi Nakada
1a47521c44
Use rb_sprintf instead of deprecated sprintf 2022-11-25 08:51:14 +09:00
Lars Kanis
439990318d Avoid warnings on MINGW:
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, ...)
      | ^~~~~~~~~~~~~~~~~
2022-11-20 11:06:28 +09:00
Samuel Williams
ea8a7287e2
Add support for sockaddr_un on Windows. (#6513)
* 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>
2022-11-17 14:50:25 -08:00
Lars Kanis
7b1d23fd29
Windows: Readlink improvements (#6745)
* 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 2ffb87995a
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 2f6fdd3aeb
2022-11-17 01:57:52 -08:00
YO4
28030f7b54 eliminate magic number 2022-09-09 00:45:56 +09:00
YO4
81e7573a64 win32.c additional fix: is_readable_console
classic console(conhost.exe) reports an input with ALT+NUMPAD as VK_MENU, KeyUp, and uChar!=0.
additional fix for #5634
2022-09-09 00:45:56 +09:00
YO4
7a849e1903 win32.c fix: is_readable_console
UnicodeChar with lower byte == 0 has dropped accidentaly
this is additional fix for #5634
2022-09-09 00:45:56 +09:00
Nobuyoshi Nakada
e2ccb316b4 [Bug #5317] Use rb_off_t instead of off_t
Get rid of the conflict with system-provided small `off_t`.
2022-09-08 23:01:07 +09:00
Nobuyoshi Nakada
58c8b6e862
Adjust styles [ci skip] 2022-08-06 10:13:20 +09:00
Takashi Kokubun
5b21e94beb Expand tabs [ci skip]
[Misc #18891]
2022-07-21 09:42:04 -07:00
Jean Boussier
d084585f01 Rename ENCINDEX_ASCII to ENCINDEX_ASCII_8BIT
Otherwise it's way too easy to confuse it with US_ASCII.
2022-07-19 08:48:56 +02:00
Nobuyoshi Nakada
ee48c9cda6
[Win32] allow pipe in flock 2022-04-21 15:14:08 +09:00
Nobuyoshi Nakada
a0040af671 [Win32] Fix mode of character/pipe device stat [Bug #18732] 2022-04-15 17:14:29 +09:00
Nobuyoshi Nakada
7b1ece9b94
Get rid of type-punning pointer casts 2022-04-07 19:19:13 +09:00
YO4
5d90c60109
Avoid console input behavior in windows 10 [Bug #18588]
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.
2022-03-16 10:28:35 +09:00
Yuta Saito
6729258839
include/ruby/win32.h: define HAVE_X for the missing prototypes (#5456) 2022-01-18 19:08:07 +09:00
nagachika
d5fc3fa4db win32/win32.c Fix PROT_EXEC bit flag check for FlushInstrucitonCache() 2021-12-30 21:16:29 +09:00
U.Nakamura
4e007d705c Fix some bornheads 2021-12-27 17:15:09 +09:00
U.Nakamura
85a426dc86 Tiny mmap emulation for Windows
- 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-12-27 15:56:23 +09:00
xtkoba
0cf9197988 Clang never evaluates expr in __builtin_assume 2021-10-04 08:13:37 +09:00
Nobuyoshi Nakada
845c017e08
Reminders of the Windows versions each API is available [ci skip] 2021-09-24 12:31:20 +09:00
xtkoba (Tee KOBAYASHI)
e32fe3ce76 MINGW: _WIN64 is not defined on i386-mingw32 + ucrt. 2021-09-20 00:15:30 +09:00
xtkoba (Tee KOBAYASHI)
4705ebd907 MINGW: Fix build error on Windows UCRT 2021-09-20 00:15:30 +09:00
Jeremy Evans
7c31ecd3ac Add parentheses to avoid pointless condition
Pointed out by xtkoba (Tee KOBAYASHI).

Fixes [Bug #17946]
2021-06-23 21:48:42 +09:00
xtkoba
44cff500a0 _MSC_VER may not be defined 2021-05-04 20:38:25 -04:00
Nobuyoshi Nakada
e85bffc324
Increment global variables atomically 2021-03-08 17:46:07 +09:00
Nobuyoshi Nakada
b7d4dcf3a6
Make vm_exit_handler installation MT-safe 2021-03-08 17:46:07 +09:00
Nobuyoshi Nakada
9299703b39
Make uenvarea thread exclusive 2021-03-08 17:46:07 +09:00
Nobuyoshi Nakada
8c943e3be8
Make the flag in thread_exclusive unique 2021-03-08 17:46:07 +09:00
Nobuyoshi Nakada
1a00402987
Enclose crtitical sections in thread_exclusive block 2021-03-08 17:45:02 +09:00
Nobuyoshi Nakada
a12e950816
Revert "Enclose crtitical sections in thread_exclusive block"
19cc24b34b and fixups.
2021-02-24 03:13:07 +09:00
Nobuyoshi Nakada
7563d542d6
Use the system getenv in setup_debug_log
As ruby_set_debug_option() is called before ruby_sysinit(),
CRITICAL_SECTIONs are not initialized yet.
2021-02-23 23:11:44 +09:00
Nobuyoshi Nakada
819dd464de
Fixed commit miss at 41eb4fbf86 2021-02-23 21:23:46 +09:00
Nobuyoshi Nakada
5a4742a0b4
Make uenvarea thread exclusive 2021-02-23 21:19:25 +09:00
Nobuyoshi Nakada
41eb4fbf86
Fixed commit miss at 19cc24b34b 2021-02-23 20:46:40 +09:00
Nobuyoshi Nakada
da18d6f015
Constified possible data 2021-02-23 19:28:03 +09:00
Nobuyoshi Nakada
19cc24b34b Enclose crtitical sections in thread_exclusive block 2021-02-23 19:03:54 +09:00
Andrew Aladjev
0d76636117 added mutexes for socket and connection lists on win32 2021-02-23 16:20:01 +09:00
Nobuyoshi Nakada
67d2619463 Expand final path name buffer for namespace prefix
As final path name includes the namespace prefix, so expand room
for it in path name buffer.
2021-02-22 19:48:15 +09:00
YO4 (Yoshinao Muramatsu)
b94b7965c4
Fixed fallback ENABLE_VIRTUAL_TERMINAL_PROCESSING value [Bug #17639] 2021-02-20 00:50:57 +09:00
xtkoba (Tee KOBAYASHI)
a681c484a3
Fixed codepage for utime [Bug #17626]
Should use the given codepage argument.

Co-Authored-By: Nobuyoshi Nakada <nobu@ruby-lang.org>
2021-02-14 19:44:41 +09:00
卜部昌平
73e948afd5 win32/win32.c:getcwd_value: delete OBJ_TAINT
Makes no sense any longer.
2021-01-27 09:30:15 +09:00
Nobuyoshi Nakada
ecfbd97292
win32: Removed never used/worked functions
Almost certainly, these have never been used in external extension
libraries.  If any had, these would have had to be declared in
headers.
2020-12-27 16:50:10 +09:00
Nobuyoshi Nakada
90dd482061
win32: Declared wait and fixed the return type 2020-12-27 16:49:27 +09:00
U.Nakamura
09f939d3a0 Enable escape sequence on Windows10 console
* win32/win32.c (init_stdhandle): enable escape sequence on
	  Windows10 console to show `ruby --help` colors correctly.
2020-12-21 17:29:09 +09:00
Nobuyoshi Nakada
37987d9994 win32: Deprecate file CP version functions 2020-12-20 18:34:04 +09:00
Nobuyoshi Nakada
95862ae440 win32: Added rb_w32_ureaddir only for UTF-8 [Feature #12654] 2020-12-20 18:34:04 +09:00
Nobuyoshi Nakada
5b98b2ce39 win32: Use UTF-8 as filesystem encoding [Feature #12654]
Co-Authored-By: Dāvis Mosāns <davispuh@gmail.com>
2020-12-20 18:34:04 +09:00