mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
ST: Define and use a new jmpbuf. v5.0.57
This commit is contained in:
parent
7d47017a00
commit
eb2056db25
8 changed files with 104 additions and 162 deletions
27
trunk/3rdparty/st-srs/tools/jmpbuf/jmpbuf.c
vendored
27
trunk/3rdparty/st-srs/tools/jmpbuf/jmpbuf.c
vendored
|
@ -4,13 +4,36 @@
|
|||
#include <stdio.h>
|
||||
#include <setjmp.h>
|
||||
|
||||
/* We define the jmpbuf, because the system's is different in different OS */
|
||||
typedef struct _st_jmp_buf {
|
||||
/*
|
||||
* OS CPU SIZE
|
||||
* Darwin __amd64__/__x86_64__ long[8]
|
||||
* Darwin __aarch64__ long[22]
|
||||
* Linux __i386__ long[6]
|
||||
* Linux __amd64__/__x86_64__ long[8]
|
||||
* Linux __aarch64__ long[22]
|
||||
* Linux __arm__ long[16]
|
||||
* Linux __mips__/__mips64 long[13]
|
||||
* Linux __riscv long[14]
|
||||
* Linux __loongarch64 long[12]
|
||||
* Cygwin64 __amd64__/__x86_64__ long[8]
|
||||
*/
|
||||
long __jmpbuf[22];
|
||||
} _st_jmp_buf_t[1];
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
jmp_buf ctx = {0};
|
||||
int r0 = setjmp(ctx);
|
||||
|
||||
int nn_jb = sizeof(ctx);
|
||||
printf("r0=%d, sizeof(jmp_buf)=%d (unsigned long long [%d])\n", r0, nn_jb, nn_jb/8);
|
||||
printf("jmp_buf: r0=%d, sizeof(jmp_buf)=%d (unsigned long long [%d])\n", r0, nn_jb, nn_jb/8);
|
||||
|
||||
_st_jmp_buf_t ctx2 = {0};
|
||||
int r1 = sizeof(_st_jmp_buf_t);
|
||||
int r2 = sizeof(ctx2);
|
||||
printf("_st_jmp_buf_t: sizeof(_st_jmp_buf_t)=%d/%d (unsigned long long [%d])\n", r1, r2, r2/8);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue