Debian Codegraph @

gcc/ada/sigtramp-android.c

raw
1 /****************************************************************************
2 * *
3 * GNAT COMPILER COMPONENTS *
4 * *
5 * S I G T R A M P *
6 * *
7 * C/Asm Implementation File *
8 * *
9 * Copyright (C) 2015-2025, Free Software Foundation, Inc. *
10 * *
11 * GNAT is free software; you can redistribute it and/or modify it under *
12 * terms of the GNU General Public License as published by the Free Soft- *
13 * ware Foundation; either version 3, or (at your option) any later ver- *
14 * sion. GNAT is distributed in the hope that it will be useful, but WITH- *
15 * OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *
16 * or FITNESS FOR A PARTICULAR PURPOSE. *
17 * *
18 * As a special exception under Section 7 of GPL version 3, you are granted *
19 * additional permissions described in the GCC Runtime Library Exception, *
20 * version 3.1, as published by the Free Software Foundation. *
21 * *
22 * In particular, you can freely distribute your programs built with the *
23 * GNAT Pro compiler, including any required library run-time units, using *
24 * any licensing terms of your choosing. See the AdaCore Software License *
25 * for full details. *
26 * *
27 * GNAT was originally developed by the GNAT team at New York University. *
28 * Extensive contributions were provided by Ada Core Technologies Inc. *
29 * *
30 ****************************************************************************/
31
32 /**************************************************
33 * Android version of the __gnat_sigtramp service *
34 **************************************************/
35
36 #include "sigtramp.h"
37
38 /* The ARM port relies on CFI info setup here. Others such as aarch64
39 rely on kernel CFI and may relay to the handler directly. */
40
41 #if defined(__arm__)
42 #define __SETUP_CFI 1
43 #else
44 #define __SETUP_CFI 0
45 #endif
46
47 #if __SETUP_CFI
48
49 /* Craft a sigtramp stub providing unwind info for common registers. */
50
51 #define TRAMP_COMMON __gnat_sigtramp_common
52 extern void TRAMP_COMMON
53 (int signo, void *siginfo, void *sigcontext,
54 __sigtramphandler_t * handler);
55
56 #include <sys/ucontext.h>
57
58 void __gnat_sigtramp (int signo, void *si, void *ucontext,
59 __sigtramphandler_t * handler)
60 {
61 struct sigcontext *mcontext = &((ucontext_t *) ucontext)->uc_mcontext;
62 TRAMP_COMMON (signo, si, mcontext, handler);
63 }
64
65 #include <sigtramp-android-asm.h>
66
67 asm (SIGTRAMP_START(TRAMP_COMMON));
68 asm (SIGTRAMP_BODY);
69 asm (SIGTRAMP_END(TRAMP_COMMON));
70
71 #else /* !__SETUP_CFI */
72
73 void __gnat_sigtramp (int signo, void *si, void *ucontext,
74 __sigtramphandler_t * handler)
75 {
76 handler (signo, si, ucontext);
77 }
78
79 #endif