xref: /netbsd-src/external/gpl3/gdb/dist/gdb/testsuite/gdb.arch/ppc64-break-on-_exit.c (revision 8e33eff89e26cf71871ead62f0d5063e1313c33a)
1 /* This file is part of GDB, the GNU debugger.
2 
3    Copyright 2021-2024 Free Software Foundation, Inc.
4 
5    This program is free software; you can redistribute it and/or modify
6    it under the terms of the GNU General Public License as published by
7    the Free Software Foundation; either version 3 of the License, or
8    (at your option) any later version.
9 
10    This program 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
13    GNU General Public License for more details.
14 
15    You should have received a copy of the GNU General Public License
16    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
17 
18 /* This file was generated from glibc's 2.31 _exit.c, by doing a glibc build
19    on ppc64le-linux, copying the command line, adding -g0 -save-temps and
20    reducing the _exit.i file.  */
21 
22 void _exit (int status);
23 
24 extern __thread int __libc_errno;
25 
26 void
27 _exit (int status)
28 {
29   while (1)
30     {
31       ({
32 	long int sc_err __attribute__ ((unused));
33 	long int sc_ret
34 	  = ({
35 	      register long int r0 __asm__ ("r0");
36 	      register long int r3 __asm__ ("r3");
37 	      register long int r4 __asm__ ("r4");
38 	      register long int r5 __asm__ ("r5");
39 	      register long int r6 __asm__ ("r6");
40 	      register long int r7 __asm__ ("r7");
41 	      register long int r8 __asm__ ("r8");
42 	      long int arg1 = (long int) (status);
43 
44 	      r0 = 234;
45 
46 	      extern void __illegally_sized_syscall_arg1 (void);
47 	      if (__builtin_classify_type (status) != 5 && sizeof (status) > 8)
48 		__illegally_sized_syscall_arg1 ();
49 
50 	      r3 = arg1;
51 	      __asm__ __volatile__ ("sc\n\t" "mfcr  %0\n\t" "0:"
52 				    : "=&r" (r0), "=&r" (r3), "=&r" (r4),
53 				      "=&r" (r5), "=&r" (r6), "=&r" (r7),
54 				      "=&r" (r8) : "0" (r0), "1" (r3)
55 				    : "r9", "r10", "r11", "r12", "cr0", "ctr", "memory");
56 	      sc_err = r0;
57 
58 	      r3;
59 	    });
60 
61 	if (((void) (sc_ret), __builtin_expect ((sc_err) & (1 << 28), 0)))
62 	  {
63 	    (__libc_errno = ((sc_ret)));
64 	    sc_ret = -1L;
65 	  }
66 
67 	sc_ret;
68       });
69 
70       ({
71 	long int sc_err __attribute__ ((unused));
72 	long int sc_ret
73 	  = ({
74 	      register long int r0 __asm__ ("r0");
75 	      register long int r3 __asm__ ("r3");
76 	      register long int r4 __asm__ ("r4");
77 	      register long int r5 __asm__ ("r5");
78 	      register long int r6 __asm__ ("r6");
79 	      register long int r7 __asm__ ("r7");
80 	      register long int r8 __asm__ ("r8");
81 	      long int arg1 = (long int) (status);
82 
83 	      r0 = 1;
84 
85 	      extern void __illegally_sized_syscall_arg1 (void);
86 	      if (__builtin_classify_type (status) != 5 && sizeof (status) > 8)
87 		__illegally_sized_syscall_arg1 ();
88 
89 	      r3 = arg1;
90 	      __asm__ __volatile__ ("sc\n\t" "mfcr  %0\n\t" "0:"
91 				    : "=&r" (r0), "=&r" (r3), "=&r" (r4),
92 				      "=&r" (r5), "=&r" (r6), "=&r" (r7),
93 				      "=&r" (r8) : "0" (r0), "1" (r3)
94 				    : "r9", "r10", "r11", "r12", "cr0", "ctr", "memory");
95 	      sc_err = r0;
96 
97 	      r3;
98 	    });
99 
100 	if (((void) (sc_ret), __builtin_expect ((sc_err) & (1 << 28), 0)))
101 	  {
102 	    (__libc_errno = ((sc_ret)));
103 	    sc_ret = -1L;
104 	  }
105 
106 	sc_ret;
107       });
108 
109 
110       asm (".long 0");
111     }
112 }
113