Fix "runs a C function with the global lock unlocked and unlocks IO with the 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`.
This commit is contained in:
parent
85b4cd7cf8
commit
6d976eb534
Notes:
git
2023-05-24 13:45:55 +00:00
Merged-By: ioquatix <samuel@codeotaku.com>
@ -148,8 +148,8 @@ typedef int clockid_t;
|
|||||||
#define close(h) rb_w32_close(h)
|
#define close(h) rb_w32_close(h)
|
||||||
#define fclose(f) rb_w32_fclose(f)
|
#define fclose(f) rb_w32_fclose(f)
|
||||||
|
|
||||||
#define read(f, b, s) rb_w32_read(f, b, s, NULL)
|
#define read(f, b, s) rb_w32_read(f, b, s)
|
||||||
#define write(f, b, s) rb_w32_write(f, b, s, NULL)
|
#define write(f, b, s) rb_w32_write(f, b, s)
|
||||||
|
|
||||||
#define HAVE_PREAD
|
#define HAVE_PREAD
|
||||||
#define pread(f, b, s, o) rb_w32_pread(f, b, s, o)
|
#define pread(f, b, s, o) rb_w32_pread(f, b, s, o)
|
||||||
@ -722,8 +722,8 @@ int rb_w32_wopen(const WCHAR *, int, ...);
|
|||||||
int rb_w32_close(int);
|
int rb_w32_close(int);
|
||||||
int rb_w32_fclose(FILE*);
|
int rb_w32_fclose(FILE*);
|
||||||
int rb_w32_pipe(int[2]);
|
int rb_w32_pipe(int[2]);
|
||||||
ssize_t rb_w32_read(int, void *, size_t, rb_off_t *offset);
|
ssize_t rb_w32_read(int, void *, size_t);
|
||||||
ssize_t rb_w32_write(int, const void *, size_t, rb_off_t *offset);
|
ssize_t rb_w32_write(int, const void *, size_t);
|
||||||
ssize_t rb_w32_pread(int, void *, size_t, rb_off_t offset);
|
ssize_t rb_w32_pread(int, void *, size_t, rb_off_t offset);
|
||||||
ssize_t rb_w32_pwrite(int, const void *, size_t, rb_off_t offset);
|
ssize_t rb_w32_pwrite(int, const void *, size_t, rb_off_t offset);
|
||||||
rb_off_t rb_w32_lseek(int, rb_off_t, int);
|
rb_off_t rb_w32_lseek(int, rb_off_t, int);
|
||||||
|
@ -8,7 +8,10 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
#define pipe(p) rb_w32_pipe(p)
|
#include "ruby/win32.h"
|
||||||
|
#define read rb_w32_read
|
||||||
|
#define write rb_w32_write
|
||||||
|
#define pipe rb_w32_pipe
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
|
@ -165,8 +165,6 @@ describe "C-API Thread function" do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# This test is disabled on Windows: https://bugs.ruby-lang.org/issues/16265
|
|
||||||
platform_is_not :mingw, :windows do
|
|
||||||
it "runs a C function with the global lock unlocked and unlocks IO with the generic RUBY_UBF_IO" do
|
it "runs a C function with the global lock unlocked and unlocks IO with the generic RUBY_UBF_IO" do
|
||||||
thr = Thread.new do
|
thr = Thread.new do
|
||||||
@t.rb_thread_call_without_gvl_with_ubf_io
|
@t.rb_thread_call_without_gvl_with_ubf_io
|
||||||
@ -186,5 +184,4 @@ describe "C-API Thread function" do
|
|||||||
thr.value.should be_true
|
thr.value.should be_true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
@ -7265,8 +7265,8 @@ finish_overlapped(OVERLAPPED *ol, int fd, DWORD size, rb_off_t *_offset)
|
|||||||
|
|
||||||
#undef read
|
#undef read
|
||||||
/* License: Ruby's */
|
/* License: Ruby's */
|
||||||
ssize_t
|
static ssize_t
|
||||||
rb_w32_read(int fd, void *buf, size_t size, rb_off_t *offset)
|
rb_w32_read_internal(int fd, void *buf, size_t size, rb_off_t *offset)
|
||||||
{
|
{
|
||||||
SOCKET sock = TO_SOCKET(fd);
|
SOCKET sock = TO_SOCKET(fd);
|
||||||
DWORD read;
|
DWORD read;
|
||||||
@ -7404,8 +7404,8 @@ rb_w32_read(int fd, void *buf, size_t size, rb_off_t *offset)
|
|||||||
|
|
||||||
#undef write
|
#undef write
|
||||||
/* License: Ruby's */
|
/* License: Ruby's */
|
||||||
ssize_t
|
static ssize_t
|
||||||
rb_w32_write(int fd, const void *buf, size_t size, rb_off_t *offset)
|
rb_w32_write_internal(int fd, const void *buf, size_t size, rb_off_t *offset)
|
||||||
{
|
{
|
||||||
SOCKET sock = TO_SOCKET(fd);
|
SOCKET sock = TO_SOCKET(fd);
|
||||||
DWORD written;
|
DWORD written;
|
||||||
@ -7510,14 +7510,28 @@ rb_w32_write(int fd, const void *buf, size_t size, rb_off_t *offset)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
ssize_t rb_w32_pread(int descriptor, void *base, size_t size, rb_off_t offset)
|
ssize_t
|
||||||
|
rb_w32_read(int fd, void *buf, size_t size)
|
||||||
{
|
{
|
||||||
return rb_w32_read(descriptor, base, size, &offset);
|
return rb_w32_read_internal(fd, buf, size, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
ssize_t rb_w32_pwrite(int descriptor, const void *base, size_t size, rb_off_t offset)
|
ssize_t
|
||||||
|
rb_w32_write(int fd, const void *buf, size_t size)
|
||||||
{
|
{
|
||||||
return rb_w32_write(descriptor, base, size, &offset);
|
return rb_w32_write_internal(fd, buf, size, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
ssize_t
|
||||||
|
rb_w32_pread(int descriptor, void *base, size_t size, rb_off_t offset)
|
||||||
|
{
|
||||||
|
return rb_w32_read_internal(descriptor, base, size, &offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
ssize_t
|
||||||
|
rb_w32_pwrite(int descriptor, const void *base, size_t size, rb_off_t offset)
|
||||||
|
{
|
||||||
|
return rb_w32_write_internal(descriptor, base, size, &offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* License: Ruby's */
|
/* License: Ruby's */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user