You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit ed53586
Browse filesBrowse the repository at this point in the historyBrowse files
vm: map every Win32 and Winsock code through MRI's errmap (#982)
* vm: map every Win32 and Winsock code through MRI's errmap (#980)
On Windows a syscall.Errno is the Win32 code itself, and errnoClasses is
keyed by the numbers Go gives the POSIX names, so every raiser that looked a
failed call's number up directly picked an unrelated class, or none.
ERROR_PATH_NOT_FOUND (3) is Go's syscall.ENOTDIR there, so a path through a
missing directory read as Errno::ENOTDIR where MRI raises Errno::ENOENT
(witnessed on #978's Windows runner, for the flush), and rmdir of a
non-empty directory (ERROR_DIR_NOT_EMPTY) fell to Errno::ENOENT.
MRI maps the code first, through errmap and rb_w32_map_errno
(win32/win32.c:145-300, v4.0.9). errnoOfError now does the same, once, so
sysFail, chdir, realpath, pwrite, the flush and the dial error all see MRI's
class. errIsErrno falls back on the mapped class, so ERROR_DIR_NOT_EMPTY is
ENOTEMPTY for rmdir, and the two direct errors.Is(err, syscall.EINVAL) checks
(File.truncate, flock) go through it.
The Winsock rows are ported in full (43, where posixErrno held 15), and
posixErrno is gone. Eight of their classes have no number in rbgo on any
target (ESHUTDOWN, ETOOMANYREFS, EHOSTDOWN, EPFNOSUPPORT, ESOCKTNOSUPPORT,
EPROCLIM, EUSERS, EREMOTE); those keep the WSA code and raise
SystemCallError, as before. TestWSARowsWithoutAClass pins that list.
Everywhere but Windows mapHostErrno is the identity.
Fixes#980
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* test: pick host error codes by the errno they MAP to
Three tests fed raw syscall.Errno values and read the class raised. On
Windows the class now follows rb_w32_map_errno, so:
- the "unclaimed errno" pickers in TestRaiseChdirErrFallbacks and
TestRaiseDialErrFallbacks chose 1, ERROR_INVALID_FUNCTION, which maps
to EINVAL and raises Errno::EINVAL;
- TestRealpathSyscallErr fed syscall.ENOTDIR, which is 3 there
(ERROR_PATH_NOT_FOUND) and maps to ENOENT, as in MRI.
unclaimedHostErrno and hostErrnoFor scan host codes through mapHostErrno,
up to 1<<16 since only codes from 10000 up are kept unmapped on Windows.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: README.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -906,6 +906,7 @@ What a target lacks, rbgo leaves out the way MRI does:
906
906
907
907
-**The store gems** — SQLite3, Sequel, ActiveRecord's adapter, Bolt, Bleve, Etcd and Confd — need modernc.org/sqlite, which has a port for darwin/{amd64,arm64}, freebsd/{386,amd64,arm,arm64}, linux/{386,amd64,arm,arm64,loong64,ppc64le,riscv64,s390x}, netbsd/amd64, openbsd/{amd64,arm64} and windows. Elsewhere (wasm included) `require` still works and the modules exist, and the first real operation raises `NotImplementedError: sqlite3 is not supported on linux/mips64le` (or the gem and target in question).
908
908
-**Errno**: a name the system's `<errno.h>` lacks is still a constant, naming `Errno::NOERROR`, as MRI's `undefined_error` does: `EMULTIHOP` and `ENOLINK` on OpenBSD, `ENOTRECOVERABLE` and `EOWNERDEAD` on NetBSD and DragonFly.
909
+
-**Errno on Windows**: a failed call's Win32 or Winsock code picks its class through MRI's own table (`errmap` and `rb_w32_map_errno` in `win32/win32.c`), so a missing directory is `Errno::ENOENT` and a refused connection `Errno::ECONNREFUSED`, as under MRI; a Win32 code absent from the table is `Errno::EINVAL`. Eight Winsock rows (`ESHUTDOWN`, `ETOOMANYREFS`, `EHOSTDOWN`, `EPFNOSUPPORT`, `ESOCKTNOSUPPORT`, `EPROCLIM`, `EUSERS`, `EREMOTE`) name classes rbgo has no number for on any target, so those failures raise plain `SystemCallError` ([#980](https://github.com/go-embedded-ruby/ruby/issues/980)).
909
910
-**`Process::RLIMIT_*`** exist only where the system has the resource: no `RLIMIT_AS` on OpenBSD, no `RLIMIT_MEMLOCK` on AIX, only `RLIMIT_AS` of the four optional ones on Solaris and illumos.
910
911
-**`File#flock`** and PStore's lock use `flock(2)`; AIX has none, so there it is emulated with `fcntl(2)` record locks, exactly as MRI's `missing/flock.c` does.
911
912
-**plan9 (386, amd64, arm) compiles and vets, and is untested at run time.** Its `syscall` package has no errno numbers (`syscall.EINVAL` is a string error there), no `Kill`, `Flock`, `Getrlimit`, `Umask` or `Stat_t`, so rbgo has a plan9 variant of each seam. Nothing has been run on a Plan 9 kernel; the one part with tests is the error-string mapping, which is pure Go and runs on every platform. What that means:
0 commit comments