remove each_id, it was never used
[clogger.git] / ext / clogger_ext / blocking_helpers.h
blobbb366ff6e23130353609b47f39d13f9c601521e7
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)
10 struct stat_args a;
12 a.path = path;
13 a.buf = 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)
19 #endif
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)
29 struct write_args a;
30 ssize_t r;
32 a.fd = fd;
33 a.buf = buf;
34 a.count = count;
35 r = (ssize_t)rb_thread_io_blocking_region(ng_write, &a, fd);
37 return r;
39 # define stat(fd,buf) my_stat((fd),(buf))
40 # define write(fd,buf,count) my_write((fd),(buf),(count))
41 #endif