正在显示
4 个修改的文件
包含
97 行增加
和
1 行删除
trunk/research/arm/jmp.cpp
0 → 100644
| 1 | +/* | ||
| 2 | + arm-linux-gnueabi-g++ -o jmp jmp.cpp -static | ||
| 3 | + arm-linux-gnueabi-strip jmp | ||
| 4 | +*/ | ||
| 5 | +#include <stdio.h> | ||
| 6 | +#include <stdlib.h> | ||
| 7 | +#include <setjmp.h> | ||
| 8 | + | ||
| 9 | +jmp_buf env_func1, env_func2; | ||
| 10 | + | ||
| 11 | +int sum = 0; | ||
| 12 | + | ||
| 13 | +void func1() { | ||
| 14 | + int ret = setjmp(env_func1); | ||
| 15 | + printf("setjmp func1 ret=%d\n", ret); | ||
| 16 | + | ||
| 17 | + if (sum <= 0) { | ||
| 18 | + return; | ||
| 19 | + } | ||
| 20 | + | ||
| 21 | + if (sum++ > 1000) { | ||
| 22 | + return; | ||
| 23 | + } | ||
| 24 | + | ||
| 25 | + // jmp to func2 | ||
| 26 | + longjmp(env_func2, 3); | ||
| 27 | +} | ||
| 28 | + | ||
| 29 | +void func2() { | ||
| 30 | + int ret = setjmp(env_func2); | ||
| 31 | + printf("setjmp func2 ret=%d\n", ret); | ||
| 32 | + | ||
| 33 | + if (sum <= 0) { | ||
| 34 | + return; | ||
| 35 | + } | ||
| 36 | + | ||
| 37 | + // jmp to func1 | ||
| 38 | + longjmp(env_func1, 2); | ||
| 39 | +} | ||
| 40 | + | ||
| 41 | +int main(int argc, char** argv) { | ||
| 42 | + printf("hello, setjmp/longjmp!\n"); | ||
| 43 | + func1(); | ||
| 44 | + sum++; | ||
| 45 | + func2(); | ||
| 46 | + printf("jmp finished, sum=%d\n", sum); | ||
| 47 | + return 0; | ||
| 48 | +} |
trunk/research/arm/jmp_sp.cpp
0 → 100644
| 1 | +/* | ||
| 2 | + arm-linux-gnueabi-g++ -g -o jmp_sp jmp_sp.cpp -static | ||
| 3 | + arm-linux-gnueabi-strip jmp_sp | ||
| 4 | +*/ | ||
| 5 | +#include <stdio.h> | ||
| 6 | +#include <stdlib.h> | ||
| 7 | +#include <setjmp.h> | ||
| 8 | + | ||
| 9 | +int main(int argc, char** argv) { | ||
| 10 | +#if defined(__amd64__) || defined(__x86_64__) | ||
| 11 | + printf("x86_64 sizeof(long int)=%d, sizeof(long)=%d, sizeof(int)=%d\n", (int)sizeof(long int), (int)sizeof(long), (int)sizeof(int)); | ||
| 12 | +#else | ||
| 13 | + printf("arm sizeof(long int)=%d, sizeof(long)=%d, sizeof(int)=%d\n", (int)sizeof(long int), (int)sizeof(long), (int)sizeof(int)); | ||
| 14 | +#endif | ||
| 15 | + | ||
| 16 | + jmp_buf env; | ||
| 17 | + | ||
| 18 | + int ret = setjmp(env); | ||
| 19 | + printf("setjmp func1 ret=%d\n", ret); | ||
| 20 | + | ||
| 21 | +#if defined(__amd64__) || defined(__x86_64__) | ||
| 22 | + // typedef lint64_t __jmp_buf[8]; | ||
| 23 | + printf("after setjmp: "); | ||
| 24 | + for (int i = 0; i < 8; i++) { | ||
| 25 | + printf("env[%d]=%#x, ", i, (int)env[0].__jmpbuf[i]); | ||
| 26 | + } | ||
| 27 | + printf("\n"); | ||
| 28 | +#else | ||
| 29 | + // typedef int32_t __jmp_buf[64] __attribute__((__aligned__ (8))); | ||
| 30 | + printf("after setjmp: "); | ||
| 31 | + for (int i = 0; i < 64; i++) { | ||
| 32 | + printf("env[%d]=%#x, ", i, (int)env[0].__jmpbuf[i]); | ||
| 33 | + } | ||
| 34 | + printf("\n"); | ||
| 35 | +#endif | ||
| 36 | + | ||
| 37 | + return 0; | ||
| 38 | +} |
trunk/research/arm/test.cpp
0 → 100644
| @@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 31 | // current release version | 31 | // current release version |
| 32 | #define VERSION_MAJOR "0" | 32 | #define VERSION_MAJOR "0" |
| 33 | #define VERSION_MINOR "9" | 33 | #define VERSION_MINOR "9" |
| 34 | -#define VERSION_REVISION "15" | 34 | +#define VERSION_REVISION "16" |
| 35 | #define RTMP_SIG_SRS_VERSION VERSION_MAJOR"."VERSION_MINOR"."VERSION_REVISION | 35 | #define RTMP_SIG_SRS_VERSION VERSION_MAJOR"."VERSION_MINOR"."VERSION_REVISION |
| 36 | // server info. | 36 | // server info. |
| 37 | #define RTMP_SIG_SRS_KEY "srs" | 37 | #define RTMP_SIG_SRS_KEY "srs" |
-
请 注册 或 登录 后发表评论