Commit 3fcbfd64
3fcbfd648b3fMerged
Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 4 files · +2 added · ~2 modified
Description
Make IO.pipe build on MinGW; add an io_pipe test
The IO.pipe lowering emitted a POSIX pipe(int[2]) call, which MinGW
doesn't provide (it exposes _pipe(fds, size, mode) via <io.h>); a
program using IO.pipe would fail to compile on the windows-mingw target.
Route the syscall through a new sp_io_make_pipe helper that calls
_pipe(fds, 65536, _O_BINARY) on WIN32 and pipe(fds) elsewhere, and
include <io.h> / <fcntl.h> in the Windows block. fdopen (already used by
sp_io_fdopen) and the sp_File* ops are available on MinGW.
Add test/io_pipe.rb so the windows-mingw CI actually exercises the path (class IO + a write/read round-trip through the pipe). Output matches CRuby on Linux; gate green (test/bench/optcarrot/self-host fixpoint).
Refs #1282.
Co-Authored-By: Claude Opus 4.8 [email protected]
Details
- Commit
- 3fcbfd648b3f
- Parent
- 7372c37f9b9f
lib/sp_runtime.hmodifiedView file
#include <windows.h>#include <process.h>#include <direct.h>#include <io.h> /* _pipe (POSIX pipe(2) is absent on MinGW) */#include <fcntl.h> /* _O_BINARY *//* POSIX compat shims for MinGW */#define mmap(a,l,p,f,fd,off) VirtualAlloc(NULL,(l),MEM_RESERVE|MEM_COMMIT,PAGE_READWRITE)#define munmap(a,l) (VirtualFree((a),0,MEM_RELEASE)?0:-1) f->mode = mode; return f;}/* pipe(2) portability: MinGW exposes _pipe(fds, size, mode) via <io.h>, not the POSIX pipe(int[2]). Returns 0 on success, -1 on error. */static int sp_io_make_pipe(int fds[2]) {#ifdef _WIN32 return _pipe(fds, 65536, _O_BINARY);#else return pipe(fds);#endif}/* IO.pipe end: wrap a raw pipe fd in a GC-managed sp_File so the sp_File_* I/O ops work on it. Same finalizer/scan as sp_File_open. */static sp_File *sp_io_fdopen(int fd, const char *mode) {spinel_codegen.rbmodifiedView file
Loading diff…
test/io_pipe.rbaddedView file
Loading diff…
test/io_pipe.rb.expectedaddedView file
Loading diff…