File tree 3 files changed +18
-1
lines changed
spec/ruby/optional/capi/ext
3 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -623,6 +623,12 @@ VALUE rb_io_path(VALUE io);
623
623
*/
624
624
int rb_io_descriptor (VALUE io);
625
625
626
+ /* *
627
+ * Get the mode of the IO.
628
+ *
629
+ */
630
+ int rb_io_mode (VALUE io);
631
+
626
632
/* *
627
633
* This function breaks down the option hash that `IO#initialize` takes into
628
634
* components. This is an implementation detail of rb_io_extract_modeenc()
Original file line number Diff line number Diff line change @@ -2869,6 +2869,13 @@ rb_io_descriptor(VALUE io)
2869
2869
}
2870
2870
}
2871
2871
2872
+ int rb_io_mode (VALUE io )
2873
+ {
2874
+ rb_io_t * fptr ;
2875
+ GetOpenFile (io , fptr );
2876
+ return fptr -> mode ;
2877
+ }
2878
+
2872
2879
/*
2873
2880
* call-seq:
2874
2881
* pid -> integer or nil
Original file line number Diff line number Diff line change @@ -307,7 +307,7 @@ VALUE io_spec_rb_io_set_nonblock(VALUE self, VALUE io) {
307
307
GetOpenFile (io , fp );
308
308
rb_io_set_nonblock (fp );
309
309
#ifdef F_GETFL
310
- flags = fcntl (fp -> fd , F_GETFL , 0 );
310
+ flags = fcntl (io_spec_get_fd ( io ) , F_GETFL , 0 );
311
311
return flags & O_NONBLOCK ? Qtrue : Qfalse ;
312
312
#else
313
313
return Qfalse ;
@@ -326,9 +326,13 @@ static VALUE io_spec_errno_set(VALUE self, VALUE val) {
326
326
}
327
327
328
328
VALUE io_spec_mode_sync_flag (VALUE self , VALUE io ) {
329
+ #ifdef RUBY_VERSION_IS_3_3
330
+ if (rb_io_mode (io ) & FMODE_SYNC ) {
331
+ #else
329
332
rb_io_t * fp ;
330
333
GetOpenFile (io , fp );
331
334
if (fp -> mode & FMODE_SYNC ) {
335
+ #endif
332
336
return Qtrue ;
333
337
} else {
334
338
return Qfalse ;
You can’t perform that action at this time.
0 commit comments