1 /* Check longjmp from user context to main context.
2 Copyright (C) 2023 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
25 static jmp_buf jmpbuf
;
26 static ucontext_t ctx
;
28 static void f2 (void);
31 __attribute__ ((noinline
, noclone
))
34 printf ("start f1\n");
39 __attribute__ ((noinline
, noclone
))
42 printf ("start f2\n");
43 if (setcontext (&ctx
) != 0)
45 printf ("%s: setcontext: %m\n", __FUNCTION__
);
53 printf ("start f3\n");
58 __attribute__ ((noinline
, noclone
))
63 if (setjmp (jmpbuf
) != 0)
66 puts ("making contexts");
67 if (getcontext (&ctx
) != 0)
69 printf ("%s: getcontext: %m\n", __FUNCTION__
);
72 ctx
.uc_stack
.ss_sp
= st1
;
73 ctx
.uc_stack
.ss_size
= sizeof st1
;
75 makecontext (&ctx
, (void (*) (void)) f3
, 0);
77 puts ("FAIL: returned from f1 ()");
87 #include <support/test-driver.c>