1 /* { dg-do run { target i?86-*-linux* x86_64-*-linux* ia64-*-linux* alpha*-*-linux* powerpc*-*-linux* s390*-*-linux* sparc*-*-linux* mips*-*-linux* } } */
2 /* { dg-options "-fasynchronous-unwind-tables -fexceptions -O2" } */
3 /* Verify that cleanups work with exception handling through realtime
10 static _Unwind_Reason_Code
11 force_unwind_stop (int version, _Unwind_Action actions,
12 _Unwind_Exception_Class exc_class,
13 struct _Unwind_Exception *exc_obj,
14 struct _Unwind_Context *context,
17 if (actions & _UA_END_OF_STACK)
19 return _URC_NO_REASON;
22 static void force_unwind ()
24 struct _Unwind_Exception *exc = malloc (sizeof (*exc));
25 exc->exception_class = 0;
26 exc->exception_cleanup = 0;
28 #ifndef __USING_SJLJ_EXCEPTIONS__
29 _Unwind_ForcedUnwind (exc, force_unwind_stop, 0);
31 _Unwind_SjLj_ForcedUnwind (exc, force_unwind_stop, 0);
40 static void counter (void *p __attribute__((unused)))
45 static void handler (void *p __attribute__((unused)))
52 static int __attribute__((noinline)) fn5 ()
54 char dummy __attribute__((cleanup (counter)));
59 static void fn4 (int sig, siginfo_t *info, void *ctx)
61 char dummy __attribute__((cleanup (counter)));
71 static int __attribute__((noinline)) fn2 ()
78 static int __attribute__((noinline)) fn1 ()
81 sigemptyset (&s.sa_mask);
83 s.sa_flags = SA_ONESHOT | SA_SIGINFO;
84 sigaction (SIGSEGV, &s, NULL);
89 static int __attribute__((noinline)) fn0 ()
91 char dummy __attribute__((cleanup (handler)));