Blame sysdeps/s390/s390-32/__longjmp.c

Packit 6c4009
/* Copyright (C) 2000-2018 Free Software Foundation, Inc.
Packit 6c4009
   This file is part of the GNU C Library.
Packit 6c4009
   Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com).
Packit 6c4009
Packit 6c4009
   The GNU C Library is free software; you can redistribute it and/or
Packit 6c4009
   modify it under the terms of the GNU Lesser General Public
Packit 6c4009
   License as published by the Free Software Foundation; either
Packit 6c4009
   version 2.1 of the License, or (at your option) any later version.
Packit 6c4009
Packit 6c4009
   The GNU C Library is distributed in the hope that it will be useful,
Packit 6c4009
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 6c4009
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 6c4009
   Lesser General Public License for more details.
Packit 6c4009
Packit 6c4009
   You should have received a copy of the GNU Lesser General Public
Packit 6c4009
   License along with the GNU C Library; if not, see
Packit 6c4009
   <http://www.gnu.org/licenses/>.  */
Packit 6c4009
Packit 6c4009
#include <errno.h>
Packit 6c4009
#include <sysdep.h>
Packit 6c4009
#include <setjmp.h>
Packit 6c4009
#include <bits/setjmp.h>
Packit 6c4009
#include <stdlib.h>
Packit 6c4009
#include <unistd.h>
Packit 6c4009
#include <stap-probe.h>
Packit 6c4009
Packit 6c4009
/* Jump to the position specified by ENV, causing the
Packit 6c4009
   setjmp call there to return VAL, or 1 if VAL is 0.  */
Packit 6c4009
void
Packit 6c4009
__longjmp (__jmp_buf env, int val)
Packit 6c4009
{
Packit 6c4009
#ifdef PTR_DEMANGLE
Packit 6c4009
  uintptr_t guard = THREAD_GET_POINTER_GUARD ();
Packit 6c4009
# ifdef CHECK_SP
Packit 6c4009
  CHECK_SP (env, guard);
Packit 6c4009
# endif
Packit 6c4009
#elif defined CHECK_SP
Packit 6c4009
  CHECK_SP (env, 0);
Packit 6c4009
#endif
Packit 6c4009
  register int r2 __asm__ ("%r2") = val == 0 ? 1 : val;
Packit 6c4009
#ifdef PTR_DEMANGLE
Packit 6c4009
  register uintptr_t r3 __asm__ ("%r3") = guard;
Packit 6c4009
  register void *r1 __asm__ ("%r1") = (void *) env;
Packit 6c4009
#endif
Packit 6c4009
  /* Restore registers and jump back.  */
Packit 6c4009
  __asm__ __volatile__ (
Packit 6c4009
		/* longjmp probe expects longjmp first argument, second
Packit 6c4009
		   argument and target address.  */
Packit 6c4009
#ifdef PTR_DEMANGLE
Packit 6c4009
			"lm   %%r4,%%r5,32(%1)\n\t"
Packit 6c4009
			"xr   %%r4,%2\n\t"
Packit 6c4009
			"xr   %%r5,%2\n\t"
Packit 6c4009
			LIBC_PROBE_ASM (longjmp, 4@%1 -4@%0 4@%%r4)
Packit 6c4009
#else
Packit 6c4009
			LIBC_PROBE_ASM (longjmp, 4@%1 -4@%0 4@%%r14)
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
			/* restore fpregs  */
Packit 6c4009
			"ld   %%f6,48(%1)\n\t"
Packit 6c4009
			"ld   %%f4,40(%1)\n\t"
Packit 6c4009
Packit 6c4009
			/* restore gregs and return to jmp_buf target  */
Packit 6c4009
#ifdef PTR_DEMANGLE
Packit 6c4009
			"lm   %%r6,%%r13,0(%1)\n\t"
Packit 6c4009
			"lr   %%r15,%%r5\n\t"
Packit 6c4009
			LIBC_PROBE_ASM (longjmp_target, 4@%1 -4@%0 4@%%r4)
Packit 6c4009
			"br   %%r4"
Packit 6c4009
#else
Packit 6c4009
			"lm   %%r6,%%r15,0(%1)\n\t"
Packit 6c4009
			LIBC_PROBE_ASM (longjmp_target, 4@%1 -4@%0 4@%%r14)
Packit 6c4009
			"br   %%r14"
Packit 6c4009
#endif
Packit 6c4009
			: : "r" (r2),
Packit 6c4009
#ifdef PTR_DEMANGLE
Packit 6c4009
			  "r" (r1), "r" (r3)
Packit 6c4009
#else
Packit 6c4009
			  "a" (env)
Packit 6c4009
#endif
Packit 6c4009
			);
Packit 6c4009
Packit 6c4009
  /* Avoid `volatile function does return' warnings.  */
Packit 6c4009
  for (;;);
Packit 6c4009
}