summaryrefslogtreecommitdiff
path: root/io.c
diff options
context:
space:
mode:
authorkosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-12-05 19:37:49 +0000
committerkosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-12-05 19:37:49 +0000
commitfe6b2e20e9f17ed2c2900aa72994e075ffdc7124 (patch)
tree13f2b2f26be57d3cd6f25b0e6483484d9dc22d1e /io.c
parentdef63c3466939161f2459f6489815b444bbde8a3 (diff)
* thread.c (rb_uninterruptible): helper function for providing
temporary async_interrupt_timing(Object => :defer) * io.c (rb_f_p): use rb_uninterruptible. * io.c (rb_f_p_internal): helper function for rb_f_p(). * io.c (struct rb_f_p_arg): new struct for rb_f_p_internal. * test/ruby/test_thread.rb (test_async_interrupt_and_p): test for the above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38225 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r--io.c48
1 files changed, 33 insertions, 15 deletions
diff --git a/io.c b/io.c
index c8a5905630..4cbce26c9c 100644
--- a/io.c
+++ b/io.c
@@ -6759,6 +6759,35 @@ rb_p(VALUE obj) /* for debug print within C code */
}
}
+struct rb_f_p_arg {
+ int argc;
+ VALUE *argv;
+};
+
+static VALUE
+rb_f_p_internal(VALUE arg)
+{
+ struct rb_f_p_arg *arg1 = (struct rb_f_p_arg*)arg;
+ int argc = arg1->argc;
+ VALUE *argv = arg1->argv;
+ int i;
+ VALUE ret = Qnil;
+
+ for (i=0; i<argc; i++) {
+ rb_p(argv[i]);
+ }
+ if (argc == 1) {
+ ret = argv[0];
+ }
+ else if (argc > 1) {
+ ret = rb_ary_new4(argc, argv);
+ }
+ if (RB_TYPE_P(rb_stdout, T_FILE)) {
+ rb_io_flush(rb_stdout);
+ }
+ return ret;
+}
+
/*
* call-seq:
* p(obj) -> obj
@@ -6780,22 +6809,11 @@ rb_p(VALUE obj) /* for debug print within C code */
static VALUE
rb_f_p(int argc, VALUE *argv, VALUE self)
{
- int i;
- VALUE ret = Qnil;
+ struct rb_f_p_arg arg;
+ arg.argc = argc;
+ arg.argv = argv;
- for (i=0; i<argc; i++) {
- rb_p(argv[i]);
- }
- if (argc == 1) {
- ret = argv[0];
- }
- else if (argc > 1) {
- ret = rb_ary_new4(argc, argv);
- }
- if (RB_TYPE_P(rb_stdout, T_FILE)) {
- rb_io_flush(rb_stdout);
- }
- return ret;
+ return rb_uninterruptible(rb_f_p_internal, (VALUE)&arg);
}
/*