mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
Merge branch 'srs.master'
This commit is contained in:
commit
eeec9c185f
3 changed files with 606 additions and 636 deletions
|
@ -67,7 +67,6 @@
|
||||||
#include "public.h"
|
#include "public.h"
|
||||||
#include "md.h"
|
#include "md.h"
|
||||||
|
|
||||||
|
|
||||||
/*****************************************
|
/*****************************************
|
||||||
* Circular linked list definitions
|
* Circular linked list definitions
|
||||||
*/
|
*/
|
||||||
|
@ -137,7 +136,6 @@ typedef struct _st_clist {
|
||||||
|
|
||||||
typedef void (*_st_destructor_t)(void *);
|
typedef void (*_st_destructor_t)(void *);
|
||||||
|
|
||||||
|
|
||||||
typedef struct _st_stack {
|
typedef struct _st_stack {
|
||||||
_st_clist_t links;
|
_st_clist_t links;
|
||||||
char *vaddr; /* Base of stack's allocated memory */
|
char *vaddr; /* Base of stack's allocated memory */
|
||||||
|
@ -317,7 +315,6 @@ extern _st_eventsys_t *_st_eventsys;
|
||||||
#define _ST_FL_INTERRUPT 0x08
|
#define _ST_FL_INTERRUPT 0x08
|
||||||
#define _ST_FL_TIMEDOUT 0x10
|
#define _ST_FL_TIMEDOUT 0x10
|
||||||
|
|
||||||
|
|
||||||
/*****************************************
|
/*****************************************
|
||||||
* Pointer conversion
|
* Pointer conversion
|
||||||
*/
|
*/
|
||||||
|
@ -456,11 +453,9 @@ int st_cond_destroy(_st_cond_t *cvar);
|
||||||
int st_cond_timedwait(_st_cond_t *cvar, st_utime_t timeout);
|
int st_cond_timedwait(_st_cond_t *cvar, st_utime_t timeout);
|
||||||
int st_cond_signal(_st_cond_t *cvar);
|
int st_cond_signal(_st_cond_t *cvar);
|
||||||
ssize_t st_read(_st_netfd_t *fd, void *buf, size_t nbyte, st_utime_t timeout);
|
ssize_t st_read(_st_netfd_t *fd, void *buf, size_t nbyte, st_utime_t timeout);
|
||||||
ssize_t st_write(_st_netfd_t *fd, const void *buf, size_t nbyte,
|
ssize_t st_write(_st_netfd_t *fd, const void *buf, size_t nbyte, st_utime_t timeout);
|
||||||
st_utime_t timeout);
|
|
||||||
int st_poll(struct pollfd *pds, int npds, st_utime_t timeout);
|
int st_poll(struct pollfd *pds, int npds, st_utime_t timeout);
|
||||||
_st_thread_t *st_thread_create(void *(*start)(void *arg), void *arg,
|
_st_thread_t *st_thread_create(void *(*start)(void *arg), void *arg, int joinable, int stk_size);
|
||||||
int joinable, int stk_size);
|
|
||||||
|
|
||||||
#endif /* !__ST_COMMON_H__ */
|
#endif /* !__ST_COMMON_H__ */
|
||||||
|
|
||||||
|
|
|
@ -57,9 +57,7 @@
|
||||||
/*****************************************
|
/*****************************************
|
||||||
* 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
|
||||||
#define MD_ACCEPT_NB_INHERITED
|
#define MD_ACCEPT_NB_INHERITED
|
||||||
|
@ -87,7 +85,6 @@
|
||||||
return (rt.tb_high * 1000000LL + rt.tb_low / 1000)
|
return (rt.tb_high * 1000000LL + rt.tb_low / 1000)
|
||||||
|
|
||||||
#elif defined (CYGWIN)
|
#elif defined (CYGWIN)
|
||||||
|
|
||||||
#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_NOT_INHERITED
|
#define MD_ACCEPT_NB_NOT_INHERITED
|
||||||
|
@ -113,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
|
||||||
|
@ -146,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
|
||||||
|
@ -178,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
|
||||||
|
@ -216,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
|
||||||
|
@ -263,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.
|
||||||
|
@ -313,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
|
||||||
|
|
||||||
|
@ -323,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.
|
||||||
|
@ -333,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
|
||||||
|
@ -345,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
|
||||||
|
|
||||||
|
@ -359,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
|
||||||
|
|
||||||
|
@ -373,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
|
||||||
|
|
||||||
|
@ -393,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
|
||||||
|
@ -408,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
|
||||||
|
@ -417,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
|
||||||
|
|
||||||
|
@ -442,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 */
|
||||||
|
@ -453,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)
|
||||||
|
@ -468,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
|
||||||
|
@ -503,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
|
||||||
|
@ -537,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
|
||||||
|
@ -561,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);
|
||||||
|
|
||||||
|
@ -607,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
|
||||||
|
|
|
@ -129,8 +129,7 @@ extern "C" {
|
||||||
extern void st_netfd_free(st_netfd_t fd);
|
extern void st_netfd_free(st_netfd_t fd);
|
||||||
extern int st_netfd_close(st_netfd_t fd);
|
extern int st_netfd_close(st_netfd_t fd);
|
||||||
extern int st_netfd_fileno(st_netfd_t fd);
|
extern int st_netfd_fileno(st_netfd_t fd);
|
||||||
extern void st_netfd_setspecific(st_netfd_t fd, void *value,
|
extern void st_netfd_setspecific(st_netfd_t fd, void *value, void (*destructor)(void *));
|
||||||
void (*destructor)(void *));
|
|
||||||
extern void *st_netfd_getspecific(st_netfd_t fd);
|
extern void *st_netfd_getspecific(st_netfd_t fd);
|
||||||
extern int st_netfd_serialize_accept(st_netfd_t fd);
|
extern int st_netfd_serialize_accept(st_netfd_t fd);
|
||||||
extern int st_netfd_poll(st_netfd_t fd, int how, st_utime_t timeout);
|
extern int st_netfd_poll(st_netfd_t fd, int how, st_utime_t timeout);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue