1 #ifdef HAVE_RB_THREAD_BLOCKING_REGION
2 struct stat_args
{ const char *path
; struct stat
*buf
; };
3 static VALUE
ng_stat(void *ptr
)
5 struct stat_args
*a
= ptr
;
6 return (VALUE
)stat(a
->path
, a
->buf
);
8 static int my_stat(const char *path
, struct stat
*buf
)
14 return (int)rb_thread_blocking_region(ng_stat
, &a
, RUBY_UBF_IO
, 0);
16 #ifndef HAVE_RB_THREAD_IO_BLOCKING_REGION
17 # define rb_thread_io_blocking_region(fn,data,fd) \
18 rb_thread_blocking_region((fn),(data), RUBY_UBF_IO, 0)
21 struct write_args
{ int fd
; const void *buf
; size_t count
; };
22 static VALUE
ng_write(void *ptr
)
24 struct write_args
*a
= ptr
;
25 return (VALUE
)write(a
->fd
, a
->buf
, a
->count
);
27 static ssize_t
my_write(int fd
, const void *buf
, size_t count
)
35 r
= (ssize_t
)rb_thread_io_blocking_region(ng_write
, &a
, fd
);
39 # define stat(fd,buf) my_stat((fd),(buf))
40 # define write(fd,buf,count) my_write((fd),(buf),(count))