Make {amd64,x86}-darwin use the direct implementations of
VG_MINIMAL_SETJMP and VG_MINIMAL_LONGJMP introduced in r12067.
With this commit, it should be possible to build a working 64 bit
Valgrind using the default gcc as supplied with Xcode 4.1 on OSX 10.7.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12070 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/coregrind/m_libcsetjmp.c b/coregrind/m_libcsetjmp.c
index 4d19e68..470ef73 100644
--- a/coregrind/m_libcsetjmp.c
+++ b/coregrind/m_libcsetjmp.c
@@ -36,8 +36,10 @@
/* See include/pub_tool_libcsetjmp.h for background and rationale. */
-/* The only alternative implementations are for ppc{32,64}-linux. See
- #259977. */
+/* The alternative implementations are for ppc{32,64}-linux and
+ {amd64,x86}-{linux,darwin}. See #259977. That leaves only
+ {arm,s390x}-linux using the gcc builtins now.
+*/
/* ------------ ppc32-linux ------------ */
@@ -271,15 +273,26 @@
#endif /* VGP_ppc64_linux */
-/* ------------ amd64-linux ------------ */
+/* ------------ amd64-{linux,darwin} ------------ */
-#if defined(VGP_amd64_linux)
+#if defined(VGP_amd64_linux) || defined(VGP_amd64_darwin)
__asm__(
".text" "\n"
"" "\n"
+
+#if defined(VGP_amd64_linux)
".global VG_MINIMAL_SETJMP" "\n" // rdi = jmp_buf
"VG_MINIMAL_SETJMP:" "\n"
+
+#elif defined(VGP_amd64_darwin)
+".globl _VG_MINIMAL_SETJMP" "\n" // rdi = jmp_buf
+"_VG_MINIMAL_SETJMP:" "\n"
+
+#else
+# error "Huh?"
+#endif
+
" movq %rax, 0(%rdi)" "\n"
" movq %rbx, 8(%rdi)" "\n"
" movq %rcx, 16(%rdi)" "\n"
@@ -304,8 +317,18 @@
" ret" "\n"
"" "\n"
-".globl VG_MINIMAL_LONGJMP" "\n"
+
+#if defined(VGP_amd64_linux)
+".global VG_MINIMAL_LONGJMP" "\n"
"VG_MINIMAL_LONGJMP:" "\n" // rdi = jmp_buf
+
+#elif defined(VGP_amd64_darwin)
+".globl _VG_MINIMAL_LONGJMP" "\n"
+"_VG_MINIMAL_LONGJMP:" "\n" // rdi = jmp_buf
+
+#else
+# error "Huh?"
+#endif
// skip restoring rax; it's pointless
" movq 8(%rdi), %rbx" "\n"
" movq 16(%rdi), %rcx" "\n"
@@ -338,21 +361,34 @@
" jmp *%rax" "\n"
"" "\n"
+#if !defined(VGP_amd64_darwin)
".previous" "\n"
+#endif
);
-#endif /* VGP_amd64_linux */
+#endif /* VGP_amd64_linux || VGP_amd64_darwin */
-/* ------------ x86-linux ------------ */
+/* ------------ x86-{linux,darwin} ------------ */
-#if defined(VGP_x86_linux)
+#if defined(VGP_x86_linux) || defined(VGP_x86_darwin)
__asm__(
".text" "\n"
"" "\n"
+
+#if defined(VGP_x86_linux)
".global VG_MINIMAL_SETJMP" "\n" // eax = jmp_buf
"VG_MINIMAL_SETJMP:" "\n"
+
+#elif defined(VGP_x86_darwin)
+".globl _VG_MINIMAL_SETJMP" "\n" // eax = jmp_buf
+"_VG_MINIMAL_SETJMP:" "\n"
+
+#else
+# error "Huh?"
+#endif
+
" movl %eax, 0(%eax)" "\n"
" movl %ebx, 4(%eax)" "\n"
" movl %ecx, 8(%eax)" "\n"
@@ -371,8 +407,19 @@
" ret" "\n"
"" "\n"
-".globl VG_MINIMAL_LONGJMP" "\n"
+
+#if defined(VGP_x86_linux)
+".global VG_MINIMAL_LONGJMP" "\n"
"VG_MINIMAL_LONGJMP:" "\n" // eax = jmp_buf
+
+#elif defined(VGP_x86_darwin)
+".globl _VG_MINIMAL_LONGJMP" "\n"
+"_VG_MINIMAL_LONGJMP:" "\n" // eax = jmp_buf
+
+#else
+# error "Huh?"
+#endif
+
// skip restoring eax; it's pointless
" movl 4(%eax), %ebx" "\n"
" movl 8(%eax), %ecx" "\n"
@@ -390,10 +437,12 @@
" jmp *%eax" "\n"
"" "\n"
+#if !defined(VGP_x86_darwin)
".previous" "\n"
+#endif
);
-#endif /* VGP_x86_linux */
+#endif /* VGP_x86_linux || VGP_x86_darwin */
/*--------------------------------------------------------------------*/
/*--- end ---*/