Commit | Line | Data |
---|---|---|
b811d2c2 | 1 | /* Copyright 2008-2020 Free Software Foundation, Inc. |
4ac33720 UW |
2 | |
3 | This file is part of GDB. | |
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 | #include <stdio.h> | |
19 | ||
d6ad07fd AA |
20 | /* Start a transaction. To avoid the need for FPR save/restore, assume |
21 | that no FP- or vector registers are modified within the transaction. | |
22 | Thus invoke TBEGIN with the "allow floating-point operation" flag set | |
23 | to zero, which forces a transaction abort when hitting an FP- or vector | |
24 | instruction. Also assume that TBEGIN will eventually succeed, so just | |
25 | retry indefinitely. */ | |
26 | ||
4ac33720 UW |
27 | static void |
28 | my_tbegin () | |
29 | { | |
30 | __asm__ volatile | |
31 | ( "1: .byte 0xe5,0x60,0x00,0x00,0xff,0x00\n" | |
32 | " jnz 1b" | |
33 | : /* no return value */ | |
34 | : /* no inputs */ | |
35 | : "cc", "memory" ); | |
36 | } | |
37 | ||
d6ad07fd AA |
38 | /* End a transaction. */ |
39 | ||
4ac33720 UW |
40 | static void |
41 | my_tend () | |
42 | { | |
43 | __asm__ volatile | |
44 | ( " .byte 0xb2,0xf8,0x00,0x00" | |
45 | : /* no return value */ | |
46 | : /* no inputs */ | |
47 | : "cc", "memory" ); | |
48 | } | |
49 | ||
50 | void | |
51 | try_transaction (void) | |
52 | { | |
53 | my_tbegin (); | |
54 | my_tend (); | |
55 | } | |
56 | ||
57 | void | |
58 | crash_in_transaction (void) | |
59 | { | |
60 | volatile char *p = 0; | |
61 | ||
62 | my_tbegin (); | |
63 | *p = 5; /* FAULT */ | |
64 | my_tend (); | |
65 | } | |
66 | ||
67 | int | |
68 | main (int argc, char *argv[]) | |
69 | { | |
70 | try_transaction (); | |
71 | crash_in_transaction (); | |
72 | return 0; | |
73 | } |