mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
research st: refine the md.h
This commit is contained in:
parent
856ba07bd3
commit
0f293802c8
1 changed files with 469 additions and 491 deletions
|
@ -57,7 +57,6 @@
|
||||||
/*****************************************
|
/*****************************************
|
||||||
* Platform specifics
|
* Platform specifics
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if defined (AIX)
|
#if defined (AIX)
|
||||||
#define MD_STACK_GROWS_DOWN
|
#define MD_STACK_GROWS_DOWN
|
||||||
#define MD_USE_SYSV_ANON_MMAP
|
#define MD_USE_SYSV_ANON_MMAP
|
||||||
|
@ -111,7 +110,6 @@
|
||||||
return (tv.tv_sec * 1000000LL + tv.tv_usec)
|
return (tv.tv_sec * 1000000LL + tv.tv_usec)
|
||||||
|
|
||||||
#elif defined (DARWIN)
|
#elif defined (DARWIN)
|
||||||
|
|
||||||
#define MD_STACK_GROWS_DOWN
|
#define MD_STACK_GROWS_DOWN
|
||||||
#define MD_USE_BSD_ANON_MMAP
|
#define MD_USE_BSD_ANON_MMAP
|
||||||
#define MD_ACCEPT_NB_INHERITED
|
#define MD_ACCEPT_NB_INHERITED
|
||||||
|
@ -144,7 +142,6 @@
|
||||||
return (tv.tv_sec * 1000000LL + tv.tv_usec)
|
return (tv.tv_sec * 1000000LL + tv.tv_usec)
|
||||||
|
|
||||||
#elif defined (FREEBSD)
|
#elif defined (FREEBSD)
|
||||||
|
|
||||||
#define MD_STACK_GROWS_DOWN
|
#define MD_STACK_GROWS_DOWN
|
||||||
#define MD_USE_BSD_ANON_MMAP
|
#define MD_USE_BSD_ANON_MMAP
|
||||||
#define MD_ACCEPT_NB_INHERITED
|
#define MD_ACCEPT_NB_INHERITED
|
||||||
|
@ -176,7 +173,6 @@
|
||||||
return (tv.tv_sec * 1000000LL + tv.tv_usec)
|
return (tv.tv_sec * 1000000LL + tv.tv_usec)
|
||||||
|
|
||||||
#elif defined (HPUX)
|
#elif defined (HPUX)
|
||||||
|
|
||||||
#define MD_STACK_GROWS_UP
|
#define MD_STACK_GROWS_UP
|
||||||
#define MD_USE_BSD_ANON_MMAP
|
#define MD_USE_BSD_ANON_MMAP
|
||||||
#define MD_ACCEPT_NB_INHERITED
|
#define MD_ACCEPT_NB_INHERITED
|
||||||
|
@ -214,7 +210,6 @@
|
||||||
return (tv.tv_sec * 1000000LL + tv.tv_usec)
|
return (tv.tv_sec * 1000000LL + tv.tv_usec)
|
||||||
|
|
||||||
#elif defined (IRIX)
|
#elif defined (IRIX)
|
||||||
|
|
||||||
#include <sys/syssgi.h>
|
#include <sys/syssgi.h>
|
||||||
|
|
||||||
#define MD_STACK_GROWS_DOWN
|
#define MD_STACK_GROWS_DOWN
|
||||||
|
@ -261,7 +256,6 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#elif defined (LINUX)
|
#elif defined (LINUX)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* These are properties of the linux kernel and are the same on every
|
* These are properties of the linux kernel and are the same on every
|
||||||
* flavor and architecture.
|
* flavor and architecture.
|
||||||
|
@ -311,7 +305,6 @@
|
||||||
(_thread)->context[0].__jmpbuf[0] = (long) (_sp); \
|
(_thread)->context[0].__jmpbuf[0] = (long) (_sp); \
|
||||||
(_thread)->context[0].__jmpbuf[17] = (long) (_bsp); \
|
(_thread)->context[0].__jmpbuf[17] = (long) (_bsp); \
|
||||||
ST_END_MACRO
|
ST_END_MACRO
|
||||||
|
|
||||||
#elif defined(__mips__)
|
#elif defined(__mips__)
|
||||||
#define MD_STACK_GROWS_DOWN
|
#define MD_STACK_GROWS_DOWN
|
||||||
|
|
||||||
|
@ -321,9 +314,7 @@
|
||||||
_thread->context[0].__jmpbuf[0].__pc = (__ptr_t) _main; \
|
_thread->context[0].__jmpbuf[0].__pc = (__ptr_t) _main; \
|
||||||
_thread->context[0].__jmpbuf[0].__sp = _sp; \
|
_thread->context[0].__jmpbuf[0].__sp = _sp; \
|
||||||
ST_END_MACRO
|
ST_END_MACRO
|
||||||
|
|
||||||
#else /* Not IA-64 or mips */
|
#else /* Not IA-64 or mips */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* On linux, there are a few styles of jmpbuf format. These vary based
|
* On linux, there are a few styles of jmpbuf format. These vary based
|
||||||
* on architecture/glibc combination.
|
* on architecture/glibc combination.
|
||||||
|
@ -331,7 +322,6 @@
|
||||||
* Most of the glibc based toggles were lifted from:
|
* Most of the glibc based toggles were lifted from:
|
||||||
* mozilla/nsprpub/pr/include/md/_linux.h
|
* mozilla/nsprpub/pr/include/md/_linux.h
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Starting with glibc 2.4, JB_SP definitions are not public anymore.
|
* Starting with glibc 2.4, JB_SP definitions are not public anymore.
|
||||||
* They, however, can still be found in glibc source tree in
|
* They, however, can still be found in glibc source tree in
|
||||||
|
@ -343,7 +333,6 @@
|
||||||
* functions as a setjmp/longjmp replacement wherever they are available
|
* functions as a setjmp/longjmp replacement wherever they are available
|
||||||
* unless USE_LIBC_SETJMP is defined.
|
* unless USE_LIBC_SETJMP is defined.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if defined(__powerpc__)
|
#if defined(__powerpc__)
|
||||||
#define MD_STACK_GROWS_DOWN
|
#define MD_STACK_GROWS_DOWN
|
||||||
|
|
||||||
|
@ -357,7 +346,6 @@
|
||||||
#error "Untested use of old glibc on powerpc"
|
#error "Untested use of old glibc on powerpc"
|
||||||
#define MD_GET_SP(_t) (_t)->context[0].__jmpbuf[0].__misc[0]
|
#define MD_GET_SP(_t) (_t)->context[0].__jmpbuf[0].__misc[0]
|
||||||
#endif /* glibc 2.1 or later */
|
#endif /* glibc 2.1 or later */
|
||||||
|
|
||||||
#elif defined(__alpha)
|
#elif defined(__alpha)
|
||||||
#define MD_STACK_GROWS_DOWN
|
#define MD_STACK_GROWS_DOWN
|
||||||
|
|
||||||
|
@ -371,13 +359,11 @@
|
||||||
#error "Untested use of old glibc on alpha"
|
#error "Untested use of old glibc on alpha"
|
||||||
#define MD_GET_SP(_t) (_t)->context[0].__jmpbuf[0].__sp
|
#define MD_GET_SP(_t) (_t)->context[0].__jmpbuf[0].__sp
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#elif defined(__mc68000__)
|
#elif defined(__mc68000__)
|
||||||
#define MD_STACK_GROWS_DOWN
|
#define MD_STACK_GROWS_DOWN
|
||||||
|
|
||||||
/* m68k still uses old style sigjmp_buf */
|
/* m68k still uses old style sigjmp_buf */
|
||||||
#define MD_GET_SP(_t) (_t)->context[0].__jmpbuf[0].__sp
|
#define MD_GET_SP(_t) (_t)->context[0].__jmpbuf[0].__sp
|
||||||
|
|
||||||
#elif defined(__sparc__)
|
#elif defined(__sparc__)
|
||||||
#define MD_STACK_GROWS_DOWN
|
#define MD_STACK_GROWS_DOWN
|
||||||
|
|
||||||
|
@ -391,7 +377,6 @@
|
||||||
#error "Untested use of old glic on sparc -- also using odd mozilla derived __fp"
|
#error "Untested use of old glic on sparc -- also using odd mozilla derived __fp"
|
||||||
#define MD_GET_SP(_t) (_t)->context[0].__jmpbuf[0].__fp
|
#define MD_GET_SP(_t) (_t)->context[0].__jmpbuf[0].__fp
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#elif defined(__i386__)
|
#elif defined(__i386__)
|
||||||
#define MD_STACK_GROWS_DOWN
|
#define MD_STACK_GROWS_DOWN
|
||||||
#define MD_USE_BUILTIN_SETJMP
|
#define MD_USE_BUILTIN_SETJMP
|
||||||
|
@ -406,7 +391,6 @@
|
||||||
#error "Untested use of old glibc on i386"
|
#error "Untested use of old glibc on i386"
|
||||||
#define MD_GET_SP(_t) (_t)->context[0].__jmpbuf[0].__sp
|
#define MD_GET_SP(_t) (_t)->context[0].__jmpbuf[0].__sp
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#elif defined(__amd64__) || defined(__x86_64__)
|
#elif defined(__amd64__) || defined(__x86_64__)
|
||||||
#define MD_STACK_GROWS_DOWN
|
#define MD_STACK_GROWS_DOWN
|
||||||
#define MD_USE_BUILTIN_SETJMP
|
#define MD_USE_BUILTIN_SETJMP
|
||||||
|
@ -415,23 +399,20 @@
|
||||||
#define JB_RSP 6
|
#define JB_RSP 6
|
||||||
#endif
|
#endif
|
||||||
#define MD_GET_SP(_t) (_t)->context[0].__jmpbuf[JB_RSP]
|
#define MD_GET_SP(_t) (_t)->context[0].__jmpbuf[JB_RSP]
|
||||||
|
|
||||||
#elif defined(__arm__)
|
#elif defined(__arm__)
|
||||||
#define MD_STACK_GROWS_DOWN
|
#define MD_STACK_GROWS_DOWN
|
||||||
|
|
||||||
#if defined(__GLIBC__) && __GLIBC__ >= 2
|
#if defined(__GLIBC__) && __GLIBC__ >= 2
|
||||||
#define MD_GET_SP(_t) (_t)->context[0].__jmpbuf[20]
|
#define MD_GET_SP(_t) (_t)->context[0].__jmpbuf[8]
|
||||||
#else
|
#else
|
||||||
#error "ARM/Linux pre-glibc2 not supported yet"
|
#error "ARM/Linux pre-glibc2 not supported yet"
|
||||||
#endif /* defined(__GLIBC__) && __GLIBC__ >= 2 */
|
#endif /* defined(__GLIBC__) && __GLIBC__ >= 2 */
|
||||||
|
|
||||||
#elif defined(__s390__)
|
#elif defined(__s390__)
|
||||||
#define MD_STACK_GROWS_DOWN
|
#define MD_STACK_GROWS_DOWN
|
||||||
|
|
||||||
/* There is no JB_SP in glibc at this time. (glibc 2.2.5)
|
/* There is no JB_SP in glibc at this time. (glibc 2.2.5)
|
||||||
*/
|
*/
|
||||||
#define MD_GET_SP(_t) (_t)->context[0].__jmpbuf[0].__gregs[9]
|
#define MD_GET_SP(_t) (_t)->context[0].__jmpbuf[0].__gregs[9]
|
||||||
|
|
||||||
#elif defined(__hppa__)
|
#elif defined(__hppa__)
|
||||||
#define MD_STACK_GROWS_UP
|
#define MD_STACK_GROWS_UP
|
||||||
|
|
||||||
|
@ -440,7 +421,6 @@
|
||||||
* use that...
|
* use that...
|
||||||
*/
|
*/
|
||||||
#define MD_GET_SP(_t) (*(long *)(((char *)&(_t)->context[0].__jmpbuf[0]) + 76))
|
#define MD_GET_SP(_t) (*(long *)(((char *)&(_t)->context[0].__jmpbuf[0]) + 76))
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#error "Unknown CPU architecture"
|
#error "Unknown CPU architecture"
|
||||||
#endif /* Cases with common MD_INIT_CONTEXT and different SP locations */
|
#endif /* Cases with common MD_INIT_CONTEXT and different SP locations */
|
||||||
|
@ -451,7 +431,6 @@
|
||||||
_main(); \
|
_main(); \
|
||||||
MD_GET_SP(_thread) = (long) (_sp); \
|
MD_GET_SP(_thread) = (long) (_sp); \
|
||||||
ST_END_MACRO
|
ST_END_MACRO
|
||||||
|
|
||||||
#endif /* Cases with different MD_INIT_CONTEXT */
|
#endif /* Cases with different MD_INIT_CONTEXT */
|
||||||
|
|
||||||
#if defined(MD_USE_BUILTIN_SETJMP) && !defined(USE_LIBC_SETJMP)
|
#if defined(MD_USE_BUILTIN_SETJMP) && !defined(USE_LIBC_SETJMP)
|
||||||
|
@ -466,7 +445,6 @@ extern void _st_md_cxt_restore(jmp_buf env, int val);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#elif defined (NETBSD)
|
#elif defined (NETBSD)
|
||||||
|
|
||||||
#define MD_STACK_GROWS_DOWN
|
#define MD_STACK_GROWS_DOWN
|
||||||
#define MD_USE_BSD_ANON_MMAP
|
#define MD_USE_BSD_ANON_MMAP
|
||||||
#define MD_ACCEPT_NB_INHERITED
|
#define MD_ACCEPT_NB_INHERITED
|
||||||
|
@ -501,7 +479,6 @@ extern void _st_md_cxt_restore(jmp_buf env, int val);
|
||||||
return (tv.tv_sec * 1000000LL + tv.tv_usec)
|
return (tv.tv_sec * 1000000LL + tv.tv_usec)
|
||||||
|
|
||||||
#elif defined (OPENBSD)
|
#elif defined (OPENBSD)
|
||||||
|
|
||||||
#define MD_STACK_GROWS_DOWN
|
#define MD_STACK_GROWS_DOWN
|
||||||
#define MD_USE_BSD_ANON_MMAP
|
#define MD_USE_BSD_ANON_MMAP
|
||||||
#define MD_ACCEPT_NB_INHERITED
|
#define MD_ACCEPT_NB_INHERITED
|
||||||
|
@ -535,7 +512,6 @@ extern void _st_md_cxt_restore(jmp_buf env, int val);
|
||||||
return (tv.tv_sec * 1000000LL + tv.tv_usec)
|
return (tv.tv_sec * 1000000LL + tv.tv_usec)
|
||||||
|
|
||||||
#elif defined (OSF1)
|
#elif defined (OSF1)
|
||||||
|
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
|
||||||
#define MD_STACK_GROWS_DOWN
|
#define MD_STACK_GROWS_DOWN
|
||||||
|
@ -559,7 +535,6 @@ extern void _st_md_cxt_restore(jmp_buf env, int val);
|
||||||
return (tv.tv_sec * 1000000LL + tv.tv_usec)
|
return (tv.tv_sec * 1000000LL + tv.tv_usec)
|
||||||
|
|
||||||
#elif defined (SOLARIS)
|
#elif defined (SOLARIS)
|
||||||
|
|
||||||
#include <sys/filio.h>
|
#include <sys/filio.h>
|
||||||
extern int getpagesize(void);
|
extern int getpagesize(void);
|
||||||
|
|
||||||
|
@ -605,6 +580,9 @@ extern int getpagesize(void);
|
||||||
#error Unknown OS
|
#error Unknown OS
|
||||||
#endif /* OS */
|
#endif /* OS */
|
||||||
|
|
||||||
|
/*****************************************
|
||||||
|
* Other defines
|
||||||
|
*/
|
||||||
#if !defined(MD_HAVE_POLL) && !defined(MD_DONT_HAVE_POLL)
|
#if !defined(MD_HAVE_POLL) && !defined(MD_DONT_HAVE_POLL)
|
||||||
#define MD_HAVE_POLL
|
#define MD_HAVE_POLL
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue