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

ST: Simplify it, only Linux/Darwin, epoll/kqueue, single process. 5.0.2

commit f4872e528cad07f8ea683cc8cb26e34111bad1b5
Author: winlin <winlin@vip.126.com>
Date:   Fri Feb 26 09:13:21 2021 +0800

    ST: For #2188: Remove sendmmsg from ST.

commit aaeb8919bd4a026268e0600398cb1e9ad477663f
Author: winlin <winlin@vip.126.com>
Date:   Thu Mar 11 08:09:54 2021 +0800

    ST: Refine utest script.

commit d1ac9da53060b6bfa82b5d041da4c2ad9bd6b90a
Author: winlin <winlin@vip.126.com>
Date:   Wed Mar 3 11:02:25 2021 +0800

    ST: Support fast utest and coverage

commit 8400115b83c022e33f59422dbf6d85ee46fb9edb
Author: winlin <winlin@vip.126.com>
Date:   Fri Feb 26 07:02:19 2021 +0800

    ST: Always use unserialized accept for linux or darwin

commit c3686f2bca80d2c139239b08975575b1bb981ffa
Author: winlin <winlin@vip.126.com>
Date:   Fri Feb 26 06:54:05 2021 +0800

    ST: Refine ARFLAGS by disable the verbose log

commit aaa5c4f863eba278c4ed2b29a46297fb01a4ed63
Author: winlin <winlin@vip.126.com>
Date:   Thu Feb 25 08:58:46 2021 +0800

    ST: Stack always grows from top to down.

commit dddd466e5c2e418c6f4896cd8bf701130052b3d9
Author: winlin <winlin@vip.126.com>
Date:   Thu Feb 25 08:51:31 2021 +0800

    ST: Ignore process fork, for single process only

commit 7906cb5f6e78c916cb8b8d9522275bfc086bb6a3
Author: winlin <winlin@vip.126.com>
Date:   Thu Feb 25 08:50:59 2021 +0800

    ST: Fix build warnings

commit d94921b84a3b6cf88ace2c766cc2bfedb9c0602e
Author: winlin <winlin@vip.126.com>
Date:   Thu Feb 25 07:27:45 2021 +0800

    ST: Remove select and poll support, only epoll and kqueue

commit 76d202514615f78d1a8f2b15778f3dac5abf4abb
Author: winlin <winlin@vip.126.com>
Date:   Thu Feb 25 07:10:47 2021 +0800

    ST: Remove multiple OS support, except Linux and Darwin.

commit 13c4ba345c61170e86dde486a174378ca235f442
Author: winlin <winlin@vip.126.com>
Date:   Thu Feb 25 06:59:35 2021 +0800

    ST: Remove __ia64__ CPU support

commit 46c06e4a11879cfeb828382e44f11287782ce4b5
Author: winlin <winlin@vip.126.com>
Date:   Wed Feb 24 11:37:27 2021 +0800

    ST: Remove unused files for ST
This commit is contained in:
winlin 2021-04-26 08:01:49 +08:00
parent 9709ca3b7e
commit 442cf615c0
37 changed files with 116 additions and 6176 deletions

View file

@ -58,66 +58,10 @@
* Platform specifics
*/
#if defined (AIX)
#if defined (DARWIN)
#define MD_STACK_GROWS_DOWN
#define MD_USE_SYSV_ANON_MMAP
#define MD_ACCEPT_NB_INHERITED
#define MD_ALWAYS_UNSERIALIZED_ACCEPT
#ifndef MD_HAVE_SOCKLEN_T
#define MD_HAVE_SOCKLEN_T
#define socklen_t unsigned long
#endif
#define MD_SETJMP(env) _setjmp(env)
#define MD_LONGJMP(env, val) _longjmp(env, val)
#define MD_INIT_CONTEXT(_thread, _sp, _main) \
ST_BEGIN_MACRO \
if (MD_SETJMP((_thread)->context)) \
_main(); \
(_thread)->context[3] = (long) (_sp); \
ST_END_MACRO
#define MD_GET_UTIME() \
timebasestruct_t rt; \
(void) read_real_time(&rt, TIMEBASE_SZ); \
(void) time_base_to_time(&rt, TIMEBASE_SZ); \
return (rt.tb_high * 1000000LL + rt.tb_low / 1000)
#elif defined (CYGWIN)
#define MD_STACK_GROWS_DOWN
#define MD_USE_BSD_ANON_MMAP
#define MD_ACCEPT_NB_NOT_INHERITED
#define MD_ALWAYS_UNSERIALIZED_ACCEPT
#define MD_SETJMP(env) setjmp(env)
#define MD_LONGJMP(env, val) longjmp(env, val)
#define MD_JB_SP 7
#define MD_GET_SP(_t) (_t)->context[MD_JB_SP]
#define MD_INIT_CONTEXT(_thread, _sp, _main) \
ST_BEGIN_MACRO \
if (MD_SETJMP((_thread)->context)) \
_main(); \
MD_GET_SP(_thread) = (long) (_sp); \
ST_END_MACRO
#define MD_GET_UTIME() \
struct timeval tv; \
(void) gettimeofday(&tv, NULL); \
return (tv.tv_sec * 1000000LL + tv.tv_usec)
#elif defined (DARWIN)
#define MD_STACK_GROWS_DOWN
#define MD_USE_BSD_ANON_MMAP
#define MD_ACCEPT_NB_INHERITED
#define MD_ALWAYS_UNSERIALIZED_ACCEPT
#define MD_HAVE_SOCKLEN_T
#define MD_USE_BUILTIN_SETJMP
@ -149,123 +93,6 @@
(void) gettimeofday(&tv, NULL); \
return (tv.tv_sec * 1000000LL + tv.tv_usec)
#elif defined (FREEBSD)
#define MD_STACK_GROWS_DOWN
#define MD_USE_BSD_ANON_MMAP
#define MD_ACCEPT_NB_INHERITED
#define MD_ALWAYS_UNSERIALIZED_ACCEPT
#define MD_SETJMP(env) _setjmp(env)
#define MD_LONGJMP(env, val) _longjmp(env, val)
#if defined(__i386__)
#define MD_JB_SP 2
#elif defined(__alpha__)
#define MD_JB_SP 34
#elif defined(__amd64__)
#define MD_JB_SP 2
#else
#error Unknown CPU architecture
#endif
#define MD_INIT_CONTEXT(_thread, _sp, _main) \
ST_BEGIN_MACRO \
if (MD_SETJMP((_thread)->context)) \
_main(); \
(_thread)->context[0]._jb[MD_JB_SP] = (long) (_sp); \
ST_END_MACRO
#define MD_GET_UTIME() \
struct timeval tv; \
(void) gettimeofday(&tv, NULL); \
return (tv.tv_sec * 1000000LL + tv.tv_usec)
#elif defined (HPUX)
#define MD_STACK_GROWS_UP
#define MD_USE_BSD_ANON_MMAP
#define MD_ACCEPT_NB_INHERITED
#define MD_ALWAYS_UNSERIALIZED_ACCEPT
#define MD_SETJMP(env) _setjmp(env)
#define MD_LONGJMP(env, val) _longjmp(env, val)
#ifndef __LP64__
/* 32-bit mode (ILP32 data model) */
#define MD_INIT_CONTEXT(_thread, _sp, _main) \
ST_BEGIN_MACRO \
if (MD_SETJMP((_thread)->context)) \
_main(); \
((long *)((_thread)->context))[1] = (long) (_sp); \
ST_END_MACRO
#else
/* 64-bit mode (LP64 data model) */
#define MD_STACK_PAD_SIZE 256
/* Last stack frame must be preserved */
#define MD_INIT_CONTEXT(_thread, _sp, _main) \
ST_BEGIN_MACRO \
if (MD_SETJMP((_thread)->context)) \
_main(); \
memcpy((char *)(_sp) - MD_STACK_PAD_SIZE, \
((char **)((_thread)->context))[1] - MD_STACK_PAD_SIZE, \
MD_STACK_PAD_SIZE); \
((long *)((_thread)->context))[1] = (long) (_sp); \
ST_END_MACRO
#endif /* !__LP64__ */
#define MD_GET_UTIME() \
struct timeval tv; \
(void) gettimeofday(&tv, NULL); \
return (tv.tv_sec * 1000000LL + tv.tv_usec)
#elif defined (IRIX)
#include <sys/syssgi.h>
#define MD_STACK_GROWS_DOWN
#define MD_USE_SYSV_ANON_MMAP
#define MD_ACCEPT_NB_INHERITED
#define MD_ALWAYS_UNSERIALIZED_ACCEPT
#define MD_SETJMP(env) setjmp(env)
#define MD_LONGJMP(env, val) longjmp(env, val)
#define MD_INIT_CONTEXT(_thread, _sp, _main) \
ST_BEGIN_MACRO \
(void) MD_SETJMP((_thread)->context); \
(_thread)->context[JB_SP] = (long) (_sp); \
(_thread)->context[JB_PC] = (long) _main; \
ST_END_MACRO
#define MD_GET_UTIME() \
static int inited = 0; \
static clockid_t clock_id = CLOCK_SGI_CYCLE; \
struct timespec ts; \
if (!inited) { \
if (syssgi(SGI_CYCLECNTR_SIZE) < 64) \
clock_id = CLOCK_REALTIME; \
inited = 1; \
} \
(void) clock_gettime(clock_id, &ts); \
return (ts.tv_sec * 1000000LL + ts.tv_nsec / 1000)
/*
* Cap the stack by zeroing out the saved return address register
* value. This allows libexc, used by SpeedShop, to know when to stop
* backtracing since it won't find main, start, or any other known
* stack root function in a state thread's stack. Without this libexc
* traces right off the stack and crashes.
* The function preamble stores ra at 8(sp), this stores zero there.
* N.B. This macro is compiler/ABI dependent. It must change if ANY more
* automatic variables are added to the _st_thread_main() routine, because
* the address where ra is stored will change.
*/
#if !defined(__GNUC__) && defined(_MIPS_SIM) && _MIPS_SIM != _ABIO32
#define MD_CAP_STACK(var_addr) \
(((volatile __uint64_t *)(var_addr))[1] = 0)
#endif
#elif defined (LINUX)
/*
@ -274,7 +101,6 @@
*/
#define MD_USE_BSD_ANON_MMAP
#define MD_ACCEPT_NB_NOT_INHERITED
#define MD_ALWAYS_UNSERIALIZED_ACCEPT
/*
* Modern GNU/Linux is Posix.1g compliant.
*/
@ -289,38 +115,7 @@
(void) gettimeofday(&tv, NULL); \
return (tv.tv_sec * 1000000LL + tv.tv_usec)
#if defined(__ia64__)
#define MD_STACK_GROWS_DOWN
/*
* IA-64 architecture. Besides traditional memory call stack, IA-64
* uses general register stack. Thus each thread needs a backing store
* for register stack in addition to memory stack. Standard
* setjmp()/longjmp() cannot be used for thread context switching
* because their implementation implicitly assumes that only one
* register stack exists.
*/
#ifdef USE_LIBC_SETJMP
#undef USE_LIBC_SETJMP
#endif
#define MD_USE_BUILTIN_SETJMP
#define MD_STACK_PAD_SIZE 128
/* Last register stack frame must be preserved */
#define MD_INIT_CONTEXT(_thread, _sp, _bsp, _main) \
ST_BEGIN_MACRO \
if (MD_SETJMP((_thread)->context)) \
_main(); \
memcpy((char *)(_bsp) - MD_STACK_PAD_SIZE, \
(char *)(_thread)->context[0].__jmpbuf[17] - MD_STACK_PAD_SIZE, \
MD_STACK_PAD_SIZE); \
(_thread)->context[0].__jmpbuf[0] = (long) (_sp); \
(_thread)->context[0].__jmpbuf[17] = (long) (_bsp); \
ST_END_MACRO
#elif defined(__mips__)
#define MD_STACK_GROWS_DOWN
#if defined(__mips__)
#define MD_INIT_CONTEXT(_thread, _sp, _main) \
ST_BEGIN_MACRO \
MD_SETJMP((_thread)->context); \
@ -328,7 +123,7 @@
_thread->context[0].__jmpbuf[0].__sp = _sp; \
ST_END_MACRO
#else /* Not IA-64 or mips */
#else /* Not mips */
/*
* On linux, there are a few styles of jmpbuf format. These vary based
@ -350,56 +145,7 @@
* unless USE_LIBC_SETJMP is defined.
*/
#if defined(__powerpc__)
#define MD_STACK_GROWS_DOWN
#if (__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1)
#ifndef JB_GPR1
#define JB_GPR1 0
#endif
#define MD_GET_SP(_t) (_t)->context[0].__jmpbuf[JB_GPR1]
#else
/* not an error but certainly cause for caution */
#error "Untested use of old glibc on powerpc"
#define MD_GET_SP(_t) (_t)->context[0].__jmpbuf[0].__misc[0]
#endif /* glibc 2.1 or later */
#elif defined(__alpha)
#define MD_STACK_GROWS_DOWN
#if defined(__GLIBC__) && __GLIBC__ >= 2
#ifndef JB_SP
#define JB_SP 8
#endif
#define MD_GET_SP(_t) (_t)->context[0].__jmpbuf[JB_SP]
#else
/* not an error but certainly cause for caution */
#error "Untested use of old glibc on alpha"
#define MD_GET_SP(_t) (_t)->context[0].__jmpbuf[0].__sp
#endif
#elif defined(__mc68000__)
#define MD_STACK_GROWS_DOWN
/* m68k still uses old style sigjmp_buf */
#define MD_GET_SP(_t) (_t)->context[0].__jmpbuf[0].__sp
#elif defined(__sparc__)
#define MD_STACK_GROWS_DOWN
#if defined(__GLIBC__) && __GLIBC__ >= 2
#ifndef JB_SP
#define JB_SP 0
#endif
#define MD_GET_SP(_t) (_t)->context[0].__jmpbuf[JB_SP]
#else
/* not an error but certainly cause for caution */
#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
#endif
#elif defined(__i386__)
#define MD_STACK_GROWS_DOWN
#if defined(__i386__)
#define MD_USE_BUILTIN_SETJMP
#if defined(__GLIBC__) && __GLIBC__ >= 2
@ -414,7 +160,6 @@
#endif
#elif defined(__amd64__) || defined(__x86_64__)
#define MD_STACK_GROWS_DOWN
#define MD_USE_BUILTIN_SETJMP
#ifndef JB_RSP
@ -424,12 +169,10 @@
#elif defined(__aarch64__)
/* https://github.com/ossrs/state-threads/issues/9 */
#define MD_STACK_GROWS_DOWN
#define MD_USE_BUILTIN_SETJMP
#define MD_GET_SP(_t) (_t)->context[0].__jmpbuf[13]
#elif defined(__arm__)
#define MD_STACK_GROWS_DOWN
/* https://github.com/ossrs/state-threads/issues/1#issuecomment-244648573 */
#define MD_USE_BUILTIN_SETJMP
@ -445,22 +188,6 @@
#error "ARM/Linux pre-glibc2 not supported yet"
#endif /* defined(__GLIBC__) && __GLIBC__ >= 2 */
#elif defined(__s390__)
#define MD_STACK_GROWS_DOWN
/* 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]
#elif defined(__hppa__)
#define MD_STACK_GROWS_UP
/* yes, this is gross, unfortunately at the moment (2002/08/01) there is
* a bug in hppa's glibc header definition for JB_SP, so we can't
* use that...
*/
#define MD_GET_SP(_t) (*(long *)(((char *)&(_t)->context[0].__jmpbuf[0]) + 76))
#else
#error "Unknown CPU architecture"
#endif /* Cases with common MD_INIT_CONTEXT and different SP locations */
@ -485,150 +212,10 @@
#define MD_LONGJMP(env, val) longjmp(env, val)
#endif
#elif defined (NETBSD)
#define MD_STACK_GROWS_DOWN
#define MD_USE_BSD_ANON_MMAP
#define MD_ACCEPT_NB_INHERITED
#define MD_ALWAYS_UNSERIALIZED_ACCEPT
#define MD_HAVE_SOCKLEN_T
#define MD_SETJMP(env) _setjmp(env)
#define MD_LONGJMP(env, val) _longjmp(env, val)
#if defined(__i386__)
#define MD_JB_SP 2
#elif defined(__alpha__)
#define MD_JB_SP 34
#elif defined(__sparc__)
#define MD_JB_SP 0
#elif defined(__vax__)
#define MD_JB_SP 2
#else
#error Unknown CPU architecture
#endif
#define MD_INIT_CONTEXT(_thread, _sp, _main) \
ST_BEGIN_MACRO \
if (MD_SETJMP((_thread)->context)) \
_main(); \
(_thread)->context[MD_JB_SP] = (long) (_sp); \
ST_END_MACRO
#define MD_GET_UTIME() \
struct timeval tv; \
(void) gettimeofday(&tv, NULL); \
return (tv.tv_sec * 1000000LL + tv.tv_usec)
#elif defined (OPENBSD)
#define MD_STACK_GROWS_DOWN
#define MD_USE_BSD_ANON_MMAP
#define MD_ACCEPT_NB_INHERITED
#define MD_ALWAYS_UNSERIALIZED_ACCEPT
#define MD_SETJMP(env) _setjmp(env)
#define MD_LONGJMP(env, val) _longjmp(env, val)
#if defined(__i386__)
#define MD_JB_SP 2
#elif defined(__alpha__)
#define MD_JB_SP 34
#elif defined(__sparc__)
#define MD_JB_SP 0
#elif defined(__amd64__)
#define MD_JB_SP 6
#else
#error Unknown CPU architecture
#endif
#define MD_INIT_CONTEXT(_thread, _sp, _main) \
ST_BEGIN_MACRO \
if (MD_SETJMP((_thread)->context)) \
_main(); \
(_thread)->context[MD_JB_SP] = (long) (_sp); \
ST_END_MACRO
#define MD_GET_UTIME() \
struct timeval tv; \
(void) gettimeofday(&tv, NULL); \
return (tv.tv_sec * 1000000LL + tv.tv_usec)
#elif defined (OSF1)
#include <signal.h>
#define MD_STACK_GROWS_DOWN
#define MD_USE_SYSV_ANON_MMAP
#define MD_ACCEPT_NB_NOT_INHERITED
#define MD_ALWAYS_UNSERIALIZED_ACCEPT
#define MD_SETJMP(env) _setjmp(env)
#define MD_LONGJMP(env, val) _longjmp(env, val)
#define MD_INIT_CONTEXT(_thread, _sp, _main) \
ST_BEGIN_MACRO \
if (MD_SETJMP((_thread)->context)) \
_main(); \
((struct sigcontext *)((_thread)->context))->sc_sp = (long) (_sp); \
ST_END_MACRO
#define MD_GET_UTIME() \
struct timeval tv; \
(void) gettimeofday(&tv, NULL); \
return (tv.tv_sec * 1000000LL + tv.tv_usec)
#elif defined (SOLARIS)
#include <sys/filio.h>
extern int getpagesize(void);
#define MD_STACK_GROWS_DOWN
#define MD_USE_SYSV_ANON_MMAP
#define MD_ACCEPT_NB_NOT_INHERITED
#define MD_SETJMP(env) setjmp(env)
#define MD_LONGJMP(env, val) longjmp(env, val)
#if defined(sparc) || defined(__sparc)
#ifdef _LP64
#define MD_STACK_PAD_SIZE 4095
#endif
#define MD_INIT_CONTEXT(_thread, _sp, _main) \
ST_BEGIN_MACRO \
(void) MD_SETJMP((_thread)->context); \
(_thread)->context[1] = (long) (_sp); \
(_thread)->context[2] = (long) _main; \
ST_END_MACRO
#elif defined(i386) || defined(__i386)
#define MD_INIT_CONTEXT(_thread, _sp, _main) \
ST_BEGIN_MACRO \
(void) MD_SETJMP((_thread)->context); \
(_thread)->context[4] = (long) (_sp); \
(_thread)->context[5] = (long) _main; \
ST_END_MACRO
#elif defined(__amd64__)
#define MD_INIT_CONTEXT(_thread, _sp, _main) \
ST_BEGIN_MACRO \
if (MD_SETJMP((_thread)->context)) \
_main(); \
(_thread)->context[6] = (long) (_sp); \
ST_END_MACRO
#else
#error Unknown CPU architecture
#endif
#define MD_GET_UTIME() \
return (gethrtime() / 1000)
#else
#error Unknown OS
#endif /* OS */
#if !defined(MD_HAVE_POLL) && !defined(MD_DONT_HAVE_POLL)
#define MD_HAVE_POLL
#endif
#ifndef MD_STACK_PAD_SIZE
#define MD_STACK_PAD_SIZE 128
#endif