1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Simplify default argument specification. (#6507)

This commit is contained in:
Samuel Williams 2022-10-07 22:51:27 +13:00 committed by GitHub
parent e4f91bbdba
commit a081fe76de
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
Notes: git 2022-10-07 18:52:00 +09:00
Merged-By: ioquatix <samuel@codeotaku.com>
3 changed files with 9 additions and 11 deletions

View file

@ -27,7 +27,6 @@ if with_config("debug") or enable_config("debug")
end end
have_func("rb_io_maybe_wait") # Ruby 3.1 have_func("rb_io_maybe_wait") # Ruby 3.1
have_func("rb_io_timeout") # Ruby 3.2
Logging::message "=== Checking for system dependent stuff... ===\n" Logging::message "=== Checking for system dependent stuff... ===\n"
have_library("nsl", "t_open") have_library("nsl", "t_open")

View file

@ -1641,21 +1641,15 @@ no_exception_p(VALUE opts)
return 0; return 0;
} }
inline static #ifndef RB_IO_TIMEOUT_DEFAULT
VALUE io_timeout() #define RB_IO_TIMEOUT_DEFAULT Qnil
{
#ifdef HAVE_RB_IO_TIMEOUT
return Qundef;
#else
return Qnil;
#endif #endif
}
static void static void
io_wait_writable(rb_io_t *fptr) io_wait_writable(rb_io_t *fptr)
{ {
#ifdef HAVE_RB_IO_MAYBE_WAIT #ifdef HAVE_RB_IO_MAYBE_WAIT
rb_io_maybe_wait_writable(errno, fptr->self, io_timeout()); rb_io_maybe_wait_writable(errno, fptr->self, RB_IO_TIMEOUT_DEFAULT);
#else #else
rb_io_wait_writable(fptr->fd); rb_io_wait_writable(fptr->fd);
#endif #endif
@ -1665,7 +1659,7 @@ static void
io_wait_readable(rb_io_t *fptr) io_wait_readable(rb_io_t *fptr)
{ {
#ifdef HAVE_RB_IO_MAYBE_WAIT #ifdef HAVE_RB_IO_MAYBE_WAIT
rb_io_maybe_wait_readable(errno, fptr->self, io_timeout()); rb_io_maybe_wait_readable(errno, fptr->self, RB_IO_TIMEOUT_DEFAULT);
#else #else
rb_io_wait_readable(fptr->fd); rb_io_wait_readable(fptr->fd);
#endif #endif

View file

@ -58,6 +58,9 @@
// IO#wait, IO#wait_readable, IO#wait_writable, IO#wait_priority are defined by this implementation. // IO#wait, IO#wait_readable, IO#wait_writable, IO#wait_priority are defined by this implementation.
#define RUBY_IO_WAIT_METHODS #define RUBY_IO_WAIT_METHODS
// Used as the default timeout argument to `rb_io_wait` to use the `IO#timeout` value.
#define RUBY_IO_TIMEOUT_DEFAULT Qundef
RBIMPL_SYMBOL_EXPORT_BEGIN() RBIMPL_SYMBOL_EXPORT_BEGIN()
struct stat; struct stat;
@ -884,6 +887,8 @@ VALUE rb_io_set_timeout(VALUE io, VALUE timeout);
* @param[in] io An IO object to wait. * @param[in] io An IO object to wait.
* @param[in] events See above. * @param[in] events See above.
* @param[in] timeout Time, or numeric seconds since UNIX epoch. * @param[in] timeout Time, or numeric seconds since UNIX epoch.
* If Qnil, wait forever. If Qundef, use the
* default timeout.
* @exception rb_eIOError `io` is not open. * @exception rb_eIOError `io` is not open.
* @exception rb_eRangeError `timeout` is out of range. * @exception rb_eRangeError `timeout` is out of range.
* @exception rb_eSystemCallError `select(2)` failed for some reason. * @exception rb_eSystemCallError `select(2)` failed for some reason.