Skip to content

Commit

Permalink
Add missing include
Browse files Browse the repository at this point in the history
45e65f3 made
ruby/internal/intern/thread.h depend on rb_wait_for_single_fd, which is
declared in ruby/io.h. However, it cannot include ruby/io.h directly due
to circular dependency issues.  So add an ruby/internal/deprecated_io.h
file with rb_wait_for_single_fd and a couple similar functions, and
have both ruby/io.h and ruby/internal/intern/thread.h include it.

Fixes [Bug #18046]
  • Loading branch information
jeremyevans committed Jul 26, 2021
1 parent c8172d0 commit d9a2e5b
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 8 deletions.
38 changes: 38 additions & 0 deletions include/ruby/internal/deprecated_io.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#ifndef RBIMPL_DEPRECATED_IO_H /*-*-C++-*-vi:se ft=cpp:*/
#define RBIMPL_DEPRECATED_IO_H
/**
* @file
* @author Ruby developers <ruby-core@ruby-lang.org>
* @copyright This file is a part of the programming language Ruby.
* Permission is hereby granted, to either redistribute and/or
* modify this file, provided that the conditions mentioned in the
* file COPYING are met. Consult the file for details.
* @warning Symbols prefixed with either `RBIMPL` or `rbimpl` are
* implementation details. Don't take them as canon. They could
* rapidly appear then vanish. The name (path) of this header file
* is also an implementation detail. Do not expect it to persist
* at the place it is now. Developers are free to move it anywhere
* anytime at will.
* @note To ruby-core: remember that this header can be possibly
* recursively included from extension libraries written in C++.
* Do not expect for instance `__VA_ARGS__` is always available.
* We assume C99 for ruby itself but we don't assume languages of
* extension libraries. They could be written in C++98.
* @brief Deprecated functions related to IO, with separate file used to
* avoid circular dependencies.
*/

RBIMPL_SYMBOL_EXPORT_BEGIN()

//RBIMPL_ATTR_DEPRECATED(("use rb_io_maybe_wait_readable"))
int rb_io_wait_readable(int fd);

//RBIMPL_ATTR_DEPRECATED(("use rb_io_maybe_wait_writable"))
int rb_io_wait_writable(int fd);

//RBIMPL_ATTR_DEPRECATED(("use rb_io_wait"))
int rb_wait_for_single_fd(int fd, int events, struct timeval *tv);

RBIMPL_SYMBOL_EXPORT_END()

#endif /* RBIMPL_DEPRECATED_IO_H */
1 change: 1 addition & 0 deletions include/ruby/internal/intern/thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
* extension libraries. They could be written in C++98.
* @brief Public APIs related to ::rb_cThread.
*/
#include "ruby/internal/deprecated_io.h"
#include "ruby/internal/config.h"
#include "ruby/internal/cast.h"
#include "ruby/internal/dllexport.h"
Expand Down
9 changes: 1 addition & 8 deletions include/ruby/io.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,14 +154,7 @@ int rb_io_extract_encoding_option(VALUE opt, rb_encoding **enc_p, rb_encoding **
void rb_io_extract_modeenc(VALUE *vmode_p, VALUE *vperm_p, VALUE opthash, int *oflags_p, int *fmode_p, rb_io_enc_t *convconfig_p);
ssize_t rb_io_bufwrite(VALUE io, const void *buf, size_t size);

//RBIMPL_ATTR_DEPRECATED(("use rb_io_maybe_wait_readable"))
int rb_io_wait_readable(int fd);

//RBIMPL_ATTR_DEPRECATED(("use rb_io_maybe_wait_writable"))
int rb_io_wait_writable(int fd);

//RBIMPL_ATTR_DEPRECATED(("use rb_io_wait"))
int rb_wait_for_single_fd(int fd, int events, struct timeval *tv);
#include "ruby/internal/deprecated_io.h"

VALUE rb_io_wait(VALUE io, VALUE events, VALUE timeout);
VALUE rb_io_maybe_wait(int error, VALUE io, VALUE events, VALUE timeout);
Expand Down

0 comments on commit d9a2e5b

Please sign in to comment.