summaryrefslogtreecommitdiff
path: root/vm_core.h
diff options
context:
space:
mode:
authornormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-04-20 21:38:27 (GMT)
committernormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-04-20 21:38:27 (GMT)
commit475b4aa40b6cf83e57176a063d368d55bf779e7c (patch)
tree569c6a6db871c4e762b293038ed456afbcf36c1c /vm_core.h
parente72a86fc9373e4477b6e275735fecdf4eac9944a (diff)
simplify altstack and enable reuse with thread cache
Instead of allocating and registering the altstack in different places, do it together to reduce code and improve readability. When thread cache is enabled, storing altstack in rb_thread_t is wasteful and we may reuse altstack in the same pthread. This also lets us clearly allow use of xmalloc to allow GC to recover from ENOMEM. [ruby-core:85621] [Feature #14487] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63213 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'vm_core.h')
-rw-r--r--vm_core.h14
1 files changed, 10 insertions, 4 deletions
diff --git a/vm_core.h b/vm_core.h
index 5fa1148..a5ba190 100644
--- a/vm_core.h
+++ b/vm_core.h
@@ -101,7 +101,13 @@
#endif
#if defined(SIGSEGV) && defined(HAVE_SIGALTSTACK) && defined(SA_SIGINFO) && !defined(__NetBSD__)
-#define USE_SIGALTSTACK
+# define USE_SIGALTSTACK
+void *rb_register_sigaltstack(void);
+# define RB_ALTSTACK_INIT(var) var = rb_register_sigaltstack()
+# define RB_ALTSTACK_FREE(var) xfree(var)
+#else /* noop */
+# define RB_ALTSTACK_INIT(var)
+# define RB_ALTSTACK_FREE(var)
#endif
/*****************/
@@ -538,6 +544,9 @@ typedef struct rb_vm_struct {
struct rb_thread_struct *main_thread;
struct rb_thread_struct *running_thread;
+#ifdef USE_SIGALTSTACK
+ void *main_altstack;
+#endif
rb_serial_t fork_gen;
struct list_head waiting_fds; /* <=> struct waiting_fd */
@@ -883,9 +892,6 @@ typedef struct rb_thread_struct {
/* misc */
unsigned int abort_on_exception: 1;
unsigned int report_on_exception: 1;
-#ifdef USE_SIGALTSTACK
- void *altstack;
-#endif
uint32_t running_time_us; /* 12500..800000 */
VALUE name;
} rb_thread_t;