OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The Native Client Authors. All rights reserved. | 2 * Copyright (c) 2012 The Native Client Authors. All rights reserved. |
3 * Use of this source code is governed by a BSD-style license that can be | 3 * Use of this source code is governed by a BSD-style license that can be |
4 * found in the LICENSE file. | 4 * found in the LICENSE file. |
5 */ | 5 */ |
6 | 6 |
7 /* This test is guarding against regressions wrt | 7 /* This test is guarding against regressions wrt |
8 __builtin_eh_return (offset, handler) | 8 __builtin_eh_return (offset, handler) |
9 especially for pnacl | 9 especially for pnacl |
10 The behavior of this builtin is not seem to be well defined. | 10 The behavior of this builtin is not seem to be well defined. |
11 It does not even exist for arm, so we empirically determine | 11 It does not even exist for arm, so we empirically determine |
12 values for STACK_REMAINDER which make the builtin | 12 values for STACK_REMAINDER which make the builtin |
13 behave like a tail-call for testing. | 13 behave like a tail-call for testing. |
14 */ | 14 */ |
15 #include "native_client/tests/toolchain/eh_helper.h" | 15 #include "native_client/tests/toolchain/eh_helper.h" |
16 #include "native_client/tests/toolchain/utils.h" | 16 #include "native_client/tests/toolchain/utils.h" |
17 | 17 |
18 | 18 |
19 void* dummy0_cfa = 0; | 19 void* dummy0_cfa = 0; |
20 void* return_address = 0; | 20 void* return_address = 0; |
21 | 21 |
22 /* STACK_REMAINDER is to compensate for the | 22 /* STACK_REMAINDER is to compensate for the |
23 * return address slot which is still on the stack on x86. | 23 * return address slot which is still on the stack on x86. |
24 */ | 24 */ |
25 #if defined(__arm__) | 25 #if defined(__arm__) |
26 #define STACK_REMAINDER 0L | 26 #define STACK_REMAINDER 0L |
| 27 #elif defined(__mips__) |
| 28 #define STACK_REMAINDER 0L |
27 #elif defined(__i386__) | 29 #elif defined(__i386__) |
28 #define STACK_REMAINDER -4L | 30 #define STACK_REMAINDER -4L |
29 #elif defined(__x86_64__) | 31 #elif defined(__x86_64__) |
30 #define STACK_REMAINDER -8L | 32 #define STACK_REMAINDER -8L |
31 #else | 33 #else |
32 #error "unknown arch" | 34 #error "unknown arch" |
33 #endif | 35 #endif |
34 | 36 |
35 /* prevent inlining, especially into main */ | 37 /* prevent inlining, especially into main */ |
36 void dummy3() __attribute__((noinline)); | 38 void dummy3() __attribute__((noinline)); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 next_step(2); | 81 next_step(2); |
80 __builtin_eh_return (STACK_REMAINDER, dummy1); | 82 __builtin_eh_return (STACK_REMAINDER, dummy1); |
81 } | 83 } |
82 | 84 |
83 int main(int argc, char* argv[]) { | 85 int main(int argc, char* argv[]) { |
84 next_step(1); | 86 next_step(1); |
85 dummy0(); | 87 dummy0(); |
86 /* Should not get here */ | 88 /* Should not get here */ |
87 abort(); | 89 abort(); |
88 } | 90 } |
OLD | NEW |