summaryrefslogtreecommitdiff
path: root/jni/ruby/sparc.c
diff options
context:
space:
mode:
authorJari Vetoniemi <jari.vetoniemi@indooratlas.com>2020-03-16 18:49:26 +0900
committerJari Vetoniemi <jari.vetoniemi@indooratlas.com>2020-03-30 00:39:06 +0900
commitfcbf63e62c627deae76c1b8cb8c0876c536ed811 (patch)
tree64cb17de3f41a2b6fef2368028fbd00349946994 /jni/ruby/sparc.c
Fresh start
Diffstat (limited to 'jni/ruby/sparc.c')
-rw-r--r--jni/ruby/sparc.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/jni/ruby/sparc.c b/jni/ruby/sparc.c
new file mode 100644
index 0000000..dc37790
--- /dev/null
+++ b/jni/ruby/sparc.c
@@ -0,0 +1,40 @@
+/********************************************************************
+ Flush register windows on sparc.
+
+ This function is in a separate file to prevent inlining. The "flushw"
+ assembler instruction used on sparcv9 flushes all register windows
+ except the current one, so if it is inlined, the current register
+ window of the process executing the instruction will not be flushed
+ correctly.
+
+ See http://bugs.ruby-lang.org/issues/5244 for discussion.
+*********************************************************************/
+void
+rb_sparc_flush_register_windows(void)
+{
+/*
+ * gcc doesn't provide "asm" keyword if -ansi and the various -std options
+ * are given.
+ * http://gcc.gnu.org/onlinedocs/gcc/Alternate-Keywords.html
+ */
+#ifndef __GNUC__
+#define __asm__ asm
+#endif
+
+ __asm__
+#ifdef __GNUC__
+ __volatile__
+#endif
+
+/* This condition should be in sync with one in configure.in */
+#if defined(__sparcv9) || defined(__sparc_v9__) || defined(__arch64__)
+# ifdef __GNUC__
+ ("flushw" : : : "%o7")
+# else
+ ("flushw")
+# endif /* __GNUC__ */
+#else
+ ("ta 0x03")
+#endif
+ ;
+}