From: Andreas Arnez Date: Wed, 15 Feb 2023 17:02:37 +0000 (+0100) Subject: Bug 465782 - s390x: Avoid __builtin_setjmp X-Git-Tag: VALGRIND_3_22_0~154 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d3ee8178e1d28c409520646a4f776eb9b946456a;p=thirdparty%2Fvalgrind.git Bug 465782 - s390x: Avoid __builtin_setjmp Currently Clang doesn't support __builtin_setjmp() on s390x. Since Valgrind already has an alternate implementation of setjmp/longjmp for many other platforms, just add one for s390x as well, to get rid of this dependency. --- diff --git a/coregrind/m_libcsetjmp.c b/coregrind/m_libcsetjmp.c index 4f1ecb1502..f53a223528 100644 --- a/coregrind/m_libcsetjmp.c +++ b/coregrind/m_libcsetjmp.c @@ -36,9 +36,9 @@ /* See include/pub_tool_libcsetjmp.h for background and rationale. */ -/* The alternative implementations are for ppc{32,64}-linux and +/* The alternative implementations are for s390x-linux, ppc{32,64}-linux, and {amd64,x86}-{linux,darwin,solaris,freebsd}. See #259977. That leaves only - {arm,s390x}-linux using the gcc builtins now. + arm-linux using the gcc builtins now. */ /* ------------ ppc32-linux ------------ */ @@ -741,6 +741,46 @@ __asm__( ); #endif /* VGP_nanomips_linux */ +/* ------------ s390x-linux ------------ */ + +#if defined(VGP_s390x_linux) +__asm__( +".text" "\n" +".align 4" "\n" +".globl VG_MINIMAL_SETJMP" "\n" +".type VG_MINIMAL_SETJMP, @function" "\n" +"VG_MINIMAL_SETJMP:" "\n" +" stmg 6,15,0(2)" "\n" +" std 8,80(2)" "\n" +" std 9,88(2)" "\n" +" std 10,96(2)" "\n" +" std 11,104(2)" "\n" +" std 12,112(2)" "\n" +" std 13,120(2)" "\n" +" std 14,128(2)" "\n" +" std 15,136(2)" "\n" +// return zero +" lghi 2,0" "\n" +" br 14" "\n" + +".align 4" "\n" +".globl VG_MINIMAL_LONGJMP" "\n" +".type VG_MINIMAL_LONGJMP, @function" "\n" +"VG_MINIMAL_LONGJMP:" "\n" +" lmg 6,15,0(2)" "\n" +" ld 8,80(2)" "\n" +" ld 9,88(2)" "\n" +" ld 10,96(2)" "\n" +" ld 11,104(2)" "\n" +" ld 12,112(2)" "\n" +" ld 13,120(2)" "\n" +" ld 14,128(2)" "\n" +" ld 15,136(2)" "\n" +// return the argument (nonzero) +" br 14" "\n" +); +#endif /* VGP_s390x_linux */ + /*--------------------------------------------------------------------*/ /*--- end ---*/ /*--------------------------------------------------------------------*/ diff --git a/include/pub_tool_libcsetjmp.h b/include/pub_tool_libcsetjmp.h index 6b278d285b..a3a386f806 100644 --- a/include/pub_tool_libcsetjmp.h +++ b/include/pub_tool_libcsetjmp.h @@ -126,6 +126,14 @@ UWord VG_MINIMAL_SETJMP(VG_MINIMAL_JMP_BUF(_env)); __attribute__((noreturn)) void VG_MINIMAL_LONGJMP(VG_MINIMAL_JMP_BUF(_env)); +#elif defined(VGP_s390x_linux) + +#define VG_MINIMAL_JMP_BUF(_name) ULong _name [10 + 8] +__attribute__((returns_twice)) +UWord VG_MINIMAL_SETJMP(VG_MINIMAL_JMP_BUF(_env)); +__attribute__((noreturn)) +void VG_MINIMAL_LONGJMP(VG_MINIMAL_JMP_BUF(_env)); + #else /* The default implementation. */