Skip to content

Commit ea15ece

Browse files
authored
Remove usage of IO internals. (#26)
1 parent f6be64c commit ea15ece

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

ext/etc/etc.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,15 @@ void rb_deprecate_constant(VALUE mod, const char *name);
6666

6767
#include "constdefs.h"
6868

69+
#ifndef HAVE_RB_IO_DESCRIPTOR
70+
static int
71+
rb_io_descriptor(VALUE io) {
72+
rb_io_t *fptr;
73+
GetOpenFile(io, fptr);
74+
return fptr->fd;
75+
}
76+
#endif
77+
6978
#ifdef HAVE_RUBY_ATOMIC_H
7079
# include "ruby/atomic.h"
7180
#else
@@ -941,14 +950,11 @@ io_pathconf(VALUE io, VALUE arg)
941950
{
942951
int name;
943952
long ret;
944-
rb_io_t *fptr;
945953

946954
name = NUM2INT(arg);
947955

948-
GetOpenFile(io, fptr);
949-
950956
errno = 0;
951-
ret = fpathconf(fptr->fd, name);
957+
ret = fpathconf(rb_io_descriptor(io), name);
952958
if (ret == -1) {
953959
if (errno == 0) /* no limit */
954960
return Qnil;

ext/etc/extconf.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@
5050
# TODO: remove when dropping 2.7 support, as exported since 3.0
5151
have_func('rb_deprecate_constant(Qnil, "None")')
5252

53+
have_func("rb_io_descriptor")
54+
5355
$distcleanfiles << "constdefs.h"
5456

5557
create_makefile("etc")

0 commit comments

Comments
 (0)