summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorSamuel Williams <[email protected]>2023-05-28 14:08:25 +0900
committergit <[email protected]>2023-05-28 05:08:40 +0000
commit00d6674636839329f54cad6daf5e5ca16cc3911e (patch)
tree468236c933e0e2ad32ecf6856631d9b7f978e92a /ext
parentcf0b9e0db04925fc7bb31366b4dc053beab0bd57 (diff)
[ruby/etc] Remove usage of IO internals.
(https://github.com/ruby/etc/pull/26) https://github.com/ruby/etc/commit/ea15eceb13
Diffstat (limited to 'ext')
-rw-r--r--ext/etc/etc.c14
-rw-r--r--ext/etc/extconf.rb2
2 files changed, 12 insertions, 4 deletions
diff --git a/ext/etc/etc.c b/ext/etc/etc.c
index 6c7145b40b..6e2374ee8c 100644
--- a/ext/etc/etc.c
+++ b/ext/etc/etc.c
@@ -66,6 +66,15 @@ void rb_deprecate_constant(VALUE mod, const char *name);
#include "constdefs.h"
+#ifndef HAVE_RB_IO_DESCRIPTOR
+static int
+rb_io_descriptor(VALUE io) {
+ rb_io_t *fptr;
+ GetOpenFile(io, fptr);
+ return fptr->fd;
+}
+#endif
+
#ifdef HAVE_RUBY_ATOMIC_H
# include "ruby/atomic.h"
#else
@@ -941,14 +950,11 @@ io_pathconf(VALUE io, VALUE arg)
{
int name;
long ret;
- rb_io_t *fptr;
name = NUM2INT(arg);
- GetOpenFile(io, fptr);
-
errno = 0;
- ret = fpathconf(fptr->fd, name);
+ ret = fpathconf(rb_io_descriptor(io), name);
if (ret == -1) {
if (errno == 0) /* no limit */
return Qnil;
diff --git a/ext/etc/extconf.rb b/ext/etc/extconf.rb
index 159b1614b7..7c30b38bfd 100644
--- a/ext/etc/extconf.rb
+++ b/ext/etc/extconf.rb
@@ -50,6 +50,8 @@ end
# TODO: remove when dropping 2.7 support, as exported since 3.0
have_func('rb_deprecate_constant(Qnil, "None")')
+have_func("rb_io_descriptor")
+
$distcleanfiles << "constdefs.h"
create_makefile("etc")