正在显示
2 个修改的文件
包含
29 行增加
和
1 行删除
trunk/research/arm/jmp_flow.cpp
0 → 100644
1 | +/* | ||
2 | +# for all supports setjmp and longjmp: | ||
3 | + g++ -g -O0 -o jmp_flow jmp_flow.cpp | ||
4 | +*/ | ||
5 | +#include <stdio.h> | ||
6 | +#include <stdlib.h> | ||
7 | +#include <setjmp.h> | ||
8 | + | ||
9 | +jmp_buf context_level_0; | ||
10 | + | ||
11 | +void func_level_0() | ||
12 | +{ | ||
13 | + const char* level_0_0 = "stack variables for func_level_0"; | ||
14 | + int ret = setjmp(context_level_0); | ||
15 | + printf("func_level_0 ret=%d\n", ret); | ||
16 | + if (ret != 0) { | ||
17 | + printf("call by longjmp.\n"); | ||
18 | + exit(0); | ||
19 | + } | ||
20 | +} | ||
21 | + | ||
22 | +int main(int argc, char** argv) | ||
23 | +{ | ||
24 | + func_level_0(); | ||
25 | + longjmp(context_level_0, 1); | ||
26 | + return 0; | ||
27 | +} |
@@ -133,7 +133,8 @@ void func0() | @@ -133,7 +133,8 @@ void func0() | ||
133 | #endif | 133 | #endif |
134 | } | 134 | } |
135 | 135 | ||
136 | -int main(int argc, char** argv) { | 136 | +int main(int argc, char** argv) |
137 | +{ | ||
137 | #if defined(__amd64__) || defined(__x86_64__) | 138 | #if defined(__amd64__) || defined(__x86_64__) |
138 | printf("x86_64 sizeof(long int)=%d, sizeof(long)=%d, " | 139 | printf("x86_64 sizeof(long int)=%d, sizeof(long)=%d, " |
139 | "sizeof(int)=%d, __WORDSIZE=%d, __GLIBC__=%d, __GLIBC_MINOR__=%d\n", | 140 | "sizeof(int)=%d, __WORDSIZE=%d, __GLIBC__=%d, __GLIBC_MINOR__=%d\n", |
-
请 注册 或 登录 后发表评论