summaryrefslogtreecommitdiff
path: root/error.c
diff options
context:
space:
mode:
author卜部昌平 <shyouhei@ruby-lang.org>2019-10-10 17:04:59 +0900
committer卜部昌平 <shyouhei@ruby-lang.org>2019-10-10 17:10:21 +0900
commitf1ce4897f2eaf9a99c250e4707e3ab6f6bdacb74 (patch)
treeb4aaa154bd492888f2e978805a3b02db4cc097f5 /error.c
parentd96f04d73a5feb15b9d27bd23af2f7325732bb03 (diff)
make rb_raise a GVL-only function again
Requested by ko1 that ability of calling rb_raise from anywhere outside of GVL is "too much". Give up that part, move the GVL aquisition routine into gc.c, and make our new gc_raise().
Diffstat (limited to 'error.c')
-rw-r--r--error.c36
1 files changed, 4 insertions, 32 deletions
diff --git a/error.c b/error.c
index 408a163f1f..0c3633c581 100644
--- a/error.c
+++ b/error.c
@@ -2605,20 +2605,10 @@ rb_enc_raise(rb_encoding *enc, VALUE exc, const char *fmt, ...)
rb_exc_raise(rb_exc_new3(exc, mesg));
}
-struct rb_raise_tag {
- VALUE exc;
- const char *fmt;
- va_list *args;
-};
-
-static void *
-rb_vraise(void *ptr)
+void
+rb_vraise(VALUE exc, const char *fmt, va_list ap)
{
- struct rb_raise_tag *argv = ptr;
- VALUE msg = rb_vsprintf(argv->fmt, *argv->args);
- VALUE exc = rb_exc_new3(argv->exc, msg);
- rb_exc_raise(exc);
- UNREACHABLE_RETURN(NULL);
+ rb_exc_raise(rb_exc_new3(exc, rb_vsprintf(fmt, ap)));
}
void
@@ -2626,25 +2616,7 @@ rb_raise(VALUE exc, const char *fmt, ...)
{
va_list args;
va_start(args, fmt);
- struct rb_raise_tag argv = {
- exc, fmt, &args,
- };
-
- if (ruby_thread_has_gvl_p()) {
- rb_vraise(&argv);
- UNREACHABLE;
- }
- else if (ruby_native_thread_p()) {
- rb_thread_call_with_gvl(rb_vraise, &argv);
- UNREACHABLE;
- }
- else {
- /* Not in a ruby thread */
- fprintf(stderr, "%s", "[FATAL] ");
- vfprintf(stderr, fmt, args);
- abort();
- }
-
+ rb_vraise(exc, fmt, args);
va_end(args);
}