1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

update the research of arm

This commit is contained in:
winlin 2014-11-07 16:47:49 +08:00
parent 0f41e0d26f
commit 1db69b153e
2 changed files with 111 additions and 34 deletions

View file

@ -1,48 +1,48 @@
/*
# see: https://github.com/winlinvip/simple-rtmp-server/wiki/v1_CN_SrsLinuxArm
arm-linux-gnueabi-g++ -o jmp jmp.cpp -static
arm-linux-gnueabi-strip jmp
g++ -g -O0 -o jmp jmp.cpp
arm-linux-gnueabi-g++ -o jmp jmp.cpp -static
arm-linux-gnueabi-strip jmp
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <setjmp.h>
bool func1_ok = false, func2_ok = false;
jmp_buf env_func1, env_func2;
int sum = 0;
void func1() {
int ret = setjmp(env_func1);
printf("setjmp func1 ret=%d\n", ret);
printf("[func1] setjmp ret=%d, sum++=%d\n", ret, sum++);
func1_ok = true;
if (sum <= 0) {
return;
}
if (sum++ > 1000) {
return;
}
sleep(1);
// jmp to func2
longjmp(env_func2, 3);
if (func2_ok) {
longjmp(env_func2, 1);
}
}
void func2() {
int ret = setjmp(env_func2);
printf("setjmp func2 ret=%d\n", ret);
printf("[func2] setjmp ret=%d, sum++=%d\n", ret, sum++);
func2_ok = true;
if (sum <= 0) {
return;
}
sleep(1);
// jmp to func1
longjmp(env_func1, 2);
if (func1_ok) {
longjmp(env_func1, 2);
}
}
int main(int argc, char** argv) {
printf("hello, setjmp/longjmp!\n");
func1();
sum++;
func2();
printf("jmp finished, sum=%d\n", sum);
return 0;