Merge branch 'srs.master'

pull/133/head
winlin 10 years ago
commit f0f27b9cb3

@ -252,10 +252,7 @@ if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
( (
rm -rf ${SRS_OBJS}/st-1.9 && cd ${SRS_OBJS} && rm -rf ${SRS_OBJS}/st-1.9 && cd ${SRS_OBJS} &&
unzip -q ../3rdparty/st-1.9.zip && cd st-1.9 && unzip -q ../3rdparty/st-1.9.zip && cd st-1.9 &&
echo "we alaways patch the st, for we may build srs under arm directly" && make ${_ST_MAKE} EXTRA_CFLAGS="-DMD_HAVE_EPOLL" &&
echo "the 1.st.arm.patch is ok for x86 because it's only modify code under macro linux arm" &&
patch -p0 < ../../3rdparty/patches/1.st.arm.patch &&
make ${_ST_MAKE} &&
cd .. && rm -rf st && ln -sf st-1.9/obj st && cd .. && rm -rf st && ln -sf st-1.9/obj st &&
cd .. && rm -f ${SRS_OBJS}/_flag.st.arm.tmp cd .. && rm -f ${SRS_OBJS}/_flag.st.arm.tmp
) )

@ -33,25 +33,20 @@ void func0()
}; };
*/ */
#if defined(__amd64__) || defined(__x86_64__) #if defined(__amd64__) || defined(__x86_64__)
/** // http://ftp.gnu.org/gnu/glibc/glibc-2.12.2.tar.xz
here, the __jmp_buf is 8*8=64 bytes // http://ftp.gnu.org/gnu/glibc/glibc-2.12.1.tar.gz
# if __WORDSIZE == 64 /*
typedef long int __jmp_buf[8]; * Starting with glibc 2.4, JB_SP definitions are not public anymore.
*/ * They, however, can still be found in glibc source tree in
/** * architecture-specific "jmpbuf-offsets.h" files.
the layout for setjmp of x86_64 * Most importantly, the content of jmp_buf is mangled by setjmp to make
# * it completely opaque (the mangling can be disabled by setting the
# The jmp_buf is assumed to contain the following, in order: * LD_POINTER_GUARD environment variable before application execution).
# %rbx * Therefore we will use built-in _st_md_cxt_save/_st_md_cxt_restore
# %rsp (post-return) * functions as a setjmp/longjmp replacement wherever they are available
# %rbp * unless USE_LIBC_SETJMP is defined.
# %r12 */
# %r13 // for glibc 2.4+, it's not possible to get and set the sp in jmp_buf
# %r14
# %r15
# <return address>
#
*/
register long int rsp0 asm("rsp"); register long int rsp0 asm("rsp");
int ret = setjmp(env_func1); int ret = setjmp(env_func1);
@ -64,7 +59,9 @@ void func0()
printf("\n"); printf("\n");
func1(); func1();
#else #endif
#if defined(__arm__)
/** /**
/usr/arm-linux-gnueabi/include/bits/setjmp.h /usr/arm-linux-gnueabi/include/bits/setjmp.h
#ifndef _ASM #ifndef _ASM
@ -115,13 +112,18 @@ void func0()
#endif #endif
} }
extern uintptr_t _jmpbuf_sp (__jmp_buf regs);
int main(int argc, char** argv) { int main(int argc, char** argv) {
#if defined(__amd64__) || defined(__x86_64__) #if defined(__amd64__) || defined(__x86_64__)
printf("x86_64 sizeof(long int)=%d, sizeof(long)=%d, sizeof(int)=%d, __WORDSIZE=%d\n", printf("x86_64 sizeof(long int)=%d, sizeof(long)=%d, "
(int)sizeof(long int), (int)sizeof(long), (int)sizeof(int), (int)__WORDSIZE); "sizeof(int)=%d, __WORDSIZE=%d, __GLIBC__=%d, __GLIBC_MINOR__=%d\n",
(int)sizeof(long int), (int)sizeof(long), (int)sizeof(int),
(int)__WORDSIZE, (int)__GLIBC__, (int)__GLIBC_MINOR__);
#else #else
printf("arm sizeof(long int)=%d, sizeof(long)=%d, sizeof(int)=%d\n", printf("arm sizeof(long int)=%d, sizeof(long)=%d, "
(int)sizeof(long int), (int)sizeof(long), (int)sizeof(int)); "sizeof(int)=%d, __GLIBC__=%d,__GLIBC_MINOR__=%d\n",
(int)sizeof(long int), (int)sizeof(long), (int)sizeof(int),
(int)__GLIBC__, (int)__GLIBC_MINOR__);
#endif #endif
func0(); func0();

@ -51,7 +51,7 @@ EXTRA_OBJS = $(TARGETDIR)/md.o
CFLAGS = CFLAGS =
OTHER_FLAGS += -Wall -g -O0 OTHER_FLAGS += -Wall -g -O0
DEFINES = -D$(OS) -DDEBUG -DMD_HAVE_EPOLL DEFINES = -D$(OS) -DDEBUG -DMD_HAVE_EPOLL -DMALLOC_STACK
########################## ##########################
# Other possible defines: # Other possible defines:

@ -1,431 +1,151 @@
/* /*
* Portions created by SGI are Copyright (C) 2000 Silicon Graphics, Inc. * Portions created by SGI are Copyright (C) 2000 Silicon Graphics, Inc.
* All Rights Reserved. * All Rights Reserved.
*/ */
#if defined(__ia64__) /****************************************************************/
/* #if defined(__i386__)
* The internal __jmp_buf layout is different from one used
* by setjmp()/longjmp(). /*
* * Internal __jmp_buf layout
* Offset Description */
* ------ ----------- #define JB_BX 0
* 0x000 stack pointer (r12) #define JB_SI 1
* 0x008 gp (r1) #define JB_DI 2
* 0x010 caller's unat #define JB_BP 3
* 0x018 fpsr #define JB_SP 4
* 0x020 r4 #define JB_PC 5
* 0x028 r5
* 0x030 r6 .file "md.S"
* 0x038 r7 .text
* 0x040 rp (b0)
* 0x048 b1 /* _st_md_cxt_save(__jmp_buf env) */
* 0x050 b2 .globl _st_md_cxt_save
* 0x058 b3 .type _st_md_cxt_save, @function
* 0x060 b4 .align 16
* 0x068 b5 _st_md_cxt_save:
* 0x070 ar.pfs movl 4(%esp), %eax
* 0x078 ar.lc
* 0x080 pr /*
* 0x088 ar.bsp * Save registers.
* 0x090 ar.unat */
* 0x098 &__jmp_buf movl %ebx, (JB_BX*4)(%eax)
* 0x0a0 ar.rsc movl %esi, (JB_SI*4)(%eax)
* 0x0a8 ar.rnat movl %edi, (JB_DI*4)(%eax)
* 0x0b0 f2 /* Save SP */
* 0x0c0 f3 leal 4(%esp), %ecx
* 0x0d0 f4 movl %ecx, (JB_SP*4)(%eax)
* 0x0e0 f5 /* Save PC we are returning to */
* 0x0f0 f16 movl 0(%esp), %ecx
* 0x100 f17 movl %ecx, (JB_PC*4)(%eax)
* 0x110 f18 /* Save caller frame pointer */
* 0x120 f19 movl %ebp, (JB_BP*4)(%eax)
* 0x130 f20 xorl %eax, %eax
* 0x130 f21 ret
* 0x140 f22 .size _st_md_cxt_save, .-_st_md_cxt_save
* 0x150 f23
* 0x160 f24
* 0x170 f25 /****************************************************************/
* 0x180 f26
* 0x190 f27 /* _st_md_cxt_restore(__jmp_buf env, int val) */
* 0x1a0 f28 .globl _st_md_cxt_restore
* 0x1b0 f29 .type _st_md_cxt_restore, @function
* 0x1c0 f30 .align 16
* 0x1d0 f31 _st_md_cxt_restore:
* /* First argument is jmp_buf */
* Note that the address of __jmp_buf is saved but not used: we assume movl 4(%esp), %ecx
* that the jmp_buf data structure is never moved around in memory. /* Second argument is return value */
*/ movl 8(%esp), %eax
/* Set the return address */
/* movl (JB_PC*4)(%ecx), %edx
* Implemented according to "IA-64 Software Conventions and Runtime /*
* Architecture Guide", Chapter 10: "Context Management". * Restore registers.
*/ */
movl (JB_BX*4)(%ecx), %ebx
.text movl (JB_SI*4)(%ecx), %esi
.psr abi64 movl (JB_DI*4)(%ecx), %edi
.psr lsb movl (JB_BP*4)(%ecx), %ebp
.lsb movl (JB_SP*4)(%ecx), %esp
testl %eax, %eax
/* _st_md_cxt_save(__jmp_buf env) */ jnz 1f
.align 32 incl %eax
.global _st_md_cxt_save /* Jump to saved PC */
.proc _st_md_cxt_save 1: jmp *%edx
_st_md_cxt_save: .size _st_md_cxt_restore, .-_st_md_cxt_restore
alloc r14 = ar.pfs,1,0,0,0
mov r16 = ar.unat /****************************************************************/
;;
mov r17 = ar.fpsr #elif defined(__amd64__) || defined(__x86_64__)
mov r2 = in0
add r3 = 8,in0 /*
;; * Internal __jmp_buf layout
st8.spill.nta [r2] = sp,16 // r12 (sp) */
;; #define JB_RBX 0
st8.spill.nta [r3] = gp,16 // r1 (gp) #define JB_RBP 1
;; #define JB_R12 2
st8.nta [r2] = r16,16 // save caller's unat #define JB_R13 3
st8.nta [r3] = r17,16 // save fpsr #define JB_R14 4
add r8 = 0xb0,in0 #define JB_R15 5
;; #define JB_RSP 6
st8.spill.nta [r2] = r4,16 // r4 #define JB_PC 7
;;
st8.spill.nta [r3] = r5,16 // r5 .file "md.S"
add r9 = 0xc0,in0 .text
;;
stf.spill.nta [r8] = f2,32 /* _st_md_cxt_save(__jmp_buf env) */
stf.spill.nta [r9] = f3,32 .globl _st_md_cxt_save
mov r15 = rp .type _st_md_cxt_save, @function
;; .align 16
stf.spill.nta [r8] = f4,32 _st_md_cxt_save:
stf.spill.nta [r9] = f5,32 /*
mov r17 = b1 * Save registers.
;; */
stf.spill.nta [r8] = f16,32 movq %rbx, (JB_RBX*8)(%rdi)
stf.spill.nta [r9] = f17,32 movq %rbp, (JB_RBP*8)(%rdi)
mov r18 = b2 movq %r12, (JB_R12*8)(%rdi)
;; movq %r13, (JB_R13*8)(%rdi)
stf.spill.nta [r8] = f18,32 movq %r14, (JB_R14*8)(%rdi)
stf.spill.nta [r9] = f19,32 movq %r15, (JB_R15*8)(%rdi)
mov r19 = b3 /* Save SP */
;; leaq 8(%rsp), %rdx
stf.spill.nta [r8] = f20,32 movq %rdx, (JB_RSP*8)(%rdi)
stf.spill.nta [r9] = f21,32 /* Save PC we are returning to */
mov r20 = b4 movq (%rsp), %rax
;; movq %rax, (JB_PC*8)(%rdi)
stf.spill.nta [r8] = f22,32 xorq %rax, %rax
stf.spill.nta [r9] = f23,32 ret
mov r21 = b5 .size _st_md_cxt_save, .-_st_md_cxt_save
;;
stf.spill.nta [r8] = f24,32
stf.spill.nta [r9] = f25,32 /****************************************************************/
mov r22 = ar.lc
;; /* _st_md_cxt_restore(__jmp_buf env, int val) */
stf.spill.nta [r8] = f26,32 .globl _st_md_cxt_restore
stf.spill.nta [r9] = f27,32 .type _st_md_cxt_restore, @function
mov r24 = pr .align 16
;; _st_md_cxt_restore:
stf.spill.nta [r8] = f28,32 /*
stf.spill.nta [r9] = f29,32 * Restore registers.
;; */
stf.spill.nta [r8] = f30 movq (JB_RBX*8)(%rdi), %rbx
stf.spill.nta [r9] = f31 movq (JB_RBP*8)(%rdi), %rbp
movq (JB_R12*8)(%rdi), %r12
st8.spill.nta [r2] = r6,16 // r6 movq (JB_R13*8)(%rdi), %r13
;; movq (JB_R14*8)(%rdi), %r14
st8.spill.nta [r3] = r7,16 // r7 movq (JB_R15*8)(%rdi), %r15
;; /* Set return value */
mov r23 = ar.bsp test %esi, %esi
mov r25 = ar.unat mov $01, %eax
cmove %eax, %esi
st8.nta [r2] = r15,16 // b0 mov %esi, %eax
st8.nta [r3] = r17,16 // b1 movq (JB_PC*8)(%rdi), %rdx
;; movq (JB_RSP*8)(%rdi), %rsp
st8.nta [r2] = r18,16 // b2 /* Jump to saved PC */
st8.nta [r3] = r19,16 // b3 jmpq *%rdx
mov r26 = ar.rsc .size _st_md_cxt_restore, .-_st_md_cxt_restore
;;
st8.nta [r2] = r20,16 // b4 /****************************************************************/
st8.nta [r3] = r21,16 // b5
;; #endif
st8.nta [r2] = r14,16 // ar.pfs
st8.nta [r3] = r22,16 // ar.lc
;;
st8.nta [r2] = r24,16 // pr
st8.nta [r3] = r23,16 // ar.bsp
;;
st8.nta [r2] = r25,16 // ar.unat
st8.nta [r3] = in0,16 // &__jmp_buf (just in case)
;;
st8.nta [r2] = r26 // ar.rsc
;;
flushrs // flush dirty regs to backing store
;;
and r27 = ~0x3,r26 // clear ar.rsc.mode
;;
mov ar.rsc = r27 // put RSE in enforced lazy mode
;;
mov r28 = ar.rnat
;;
st8.nta [r3] = r28 // ar.rnat
mov ar.rsc = r26 // restore ar.rsc
;;
mov r8 = 0
br.ret.sptk.few b0
.endp _st_md_cxt_save
/****************************************************************/
/* _st_md_cxt_restore(__jmp_buf env, int val) */
.global _st_md_cxt_restore
.proc _st_md_cxt_restore
_st_md_cxt_restore:
alloc r8 = ar.pfs,2,0,0,0
add r2 = 0x88,in0 // r2 <- &jmpbuf.ar_bsp
mov r16 = ar.rsc
;;
flushrs // flush dirty regs to backing store
;;
and r17 = ~0x3,r16 // clear ar.rsc.mode
;;
mov ar.rsc = r17 // put RSE in enforced lazy mode
;;
invala // invalidate the ALAT
;;
ld8 r23 = [r2],8 // r23 <- jmpbuf.ar_bsp
;;
mov ar.bspstore = r23 // write BSPSTORE
ld8 r25 = [r2],24 // r25 <- jmpbuf.ar_unat
;;
ld8 r26 = [r2],-8 // r26 <- jmpbuf.ar_rnat
;;
mov ar.rnat = r26 // write RNAT
ld8 r27 = [r2] // r27 <- jmpbuf.ar_rsc
;;
mov ar.rsc = r27 // write RSE control
mov r2 = in0
;;
mov ar.unat = r25 // write ar.unat
add r3 = 8,in0
;;
ld8.fill.nta sp = [r2],16 // r12 (sp)
ld8.fill.nta gp = [r3],16 // r1 (gp)
;;
ld8.nta r16 = [r2],16 // caller's unat
ld8.nta r17 = [r3],16 // fpsr
;;
ld8.fill.nta r4 = [r2],16 // r4
ld8.fill.nta r5 = [r3],16 // r5
;;
ld8.fill.nta r6 = [r2],16 // r6
ld8.fill.nta r7 = [r3],16 // r7
;;
mov ar.unat = r16 // restore caller's unat
mov ar.fpsr = r17 // restore fpsr
;;
ld8.nta r16 = [r2],16 // b0
ld8.nta r17 = [r3],16 // b1
;;
ld8.nta r18 = [r2],16 // b2
ld8.nta r19 = [r3],16 // b3
;;
ld8.nta r20 = [r2],16 // b4
ld8.nta r21 = [r3],16 // b5
;;
ld8.nta r11 = [r2],16 // ar.pfs
ld8.nta r22 = [r3],72 // ar.lc
;;
ld8.nta r24 = [r2],48 // pr
mov b0 = r16
;;
ldf.fill.nta f2 = [r2],32
ldf.fill.nta f3 = [r3],32
mov b1 = r17
;;
ldf.fill.nta f4 = [r2],32
ldf.fill.nta f5 = [r3],32
mov b2 = r18
;;
ldf.fill.nta f16 = [r2],32
ldf.fill.nta f17 = [r3],32
mov b3 = r19
;;
ldf.fill.nta f18 = [r2],32
ldf.fill.nta f19 = [r3],32
mov b4 = r20
;;
ldf.fill.nta f20 = [r2],32
ldf.fill.nta f21 = [r3],32
mov b5 = r21
;;
ldf.fill.nta f22 = [r2],32
ldf.fill.nta f23 = [r3],32
mov ar.lc = r22
;;
ldf.fill.nta f24 = [r2],32
ldf.fill.nta f25 = [r3],32
cmp.eq p6,p7 = 0,in1
;;
ldf.fill.nta f26 = [r2],32
ldf.fill.nta f27 = [r3],32
mov ar.pfs = r11
;;
ldf.fill.nta f28 = [r2],32
ldf.fill.nta f29 = [r3],32
;;
ldf.fill.nta f30 = [r2]
ldf.fill.nta f31 = [r3]
(p6) mov r8 = 1
(p7) mov r8 = in1
mov pr = r24,-1
br.ret.sptk.few b0
.endp _st_md_cxt_restore
/****************************************************************/
#elif defined(__i386__)
/*
* Internal __jmp_buf layout
*/
#define JB_BX 0
#define JB_SI 1
#define JB_DI 2
#define JB_BP 3
#define JB_SP 4
#define JB_PC 5
.file "md.S"
.text
/* _st_md_cxt_save(__jmp_buf env) */
.globl _st_md_cxt_save
.type _st_md_cxt_save, @function
.align 16
_st_md_cxt_save:
movl 4(%esp), %eax
/*
* Save registers.
*/
movl %ebx, (JB_BX*4)(%eax)
movl %esi, (JB_SI*4)(%eax)
movl %edi, (JB_DI*4)(%eax)
/* Save SP */
leal 4(%esp), %ecx
movl %ecx, (JB_SP*4)(%eax)
/* Save PC we are returning to */
movl 0(%esp), %ecx
movl %ecx, (JB_PC*4)(%eax)
/* Save caller frame pointer */
movl %ebp, (JB_BP*4)(%eax)
xorl %eax, %eax
ret
.size _st_md_cxt_save, .-_st_md_cxt_save
/****************************************************************/
/* _st_md_cxt_restore(__jmp_buf env, int val) */
.globl _st_md_cxt_restore
.type _st_md_cxt_restore, @function
.align 16
_st_md_cxt_restore:
/* First argument is jmp_buf */
movl 4(%esp), %ecx
/* Second argument is return value */
movl 8(%esp), %eax
/* Set the return address */
movl (JB_PC*4)(%ecx), %edx
/*
* Restore registers.
*/
movl (JB_BX*4)(%ecx), %ebx
movl (JB_SI*4)(%ecx), %esi
movl (JB_DI*4)(%ecx), %edi
movl (JB_BP*4)(%ecx), %ebp
movl (JB_SP*4)(%ecx), %esp
testl %eax, %eax
jnz 1f
incl %eax
/* Jump to saved PC */
1: jmp *%edx
.size _st_md_cxt_restore, .-_st_md_cxt_restore
/****************************************************************/
#elif defined(__amd64__) || defined(__x86_64__)
/*
* Internal __jmp_buf layout
*/
#define JB_RBX 0
#define JB_RBP 1
#define JB_R12 2
#define JB_R13 3
#define JB_R14 4
#define JB_R15 5
#define JB_RSP 6
#define JB_PC 7
.file "md.S"
.text
/* _st_md_cxt_save(__jmp_buf env) */
.globl _st_md_cxt_save
.type _st_md_cxt_save, @function
.align 16
_st_md_cxt_save:
/*
* Save registers.
*/
movq %rbx, (JB_RBX*8)(%rdi)
movq %rbp, (JB_RBP*8)(%rdi)
movq %r12, (JB_R12*8)(%rdi)
movq %r13, (JB_R13*8)(%rdi)
movq %r14, (JB_R14*8)(%rdi)
movq %r15, (JB_R15*8)(%rdi)
/* Save SP */
leaq 8(%rsp), %rdx
movq %rdx, (JB_RSP*8)(%rdi)
/* Save PC we are returning to */
movq (%rsp), %rax
movq %rax, (JB_PC*8)(%rdi)
xorq %rax, %rax
ret
.size _st_md_cxt_save, .-_st_md_cxt_save
/****************************************************************/
/* _st_md_cxt_restore(__jmp_buf env, int val) */
.globl _st_md_cxt_restore
.type _st_md_cxt_restore, @function
.align 16
_st_md_cxt_restore:
/*
* Restore registers.
*/
movq (JB_RBX*8)(%rdi), %rbx
movq (JB_RBP*8)(%rdi), %rbp
movq (JB_R12*8)(%rdi), %r12
movq (JB_R13*8)(%rdi), %r13
movq (JB_R14*8)(%rdi), %r14
movq (JB_R15*8)(%rdi), %r15
/* Set return value */
test %esi, %esi
mov $01, %eax
cmove %eax, %esi
mov %esi, %eax
movq (JB_PC*8)(%rdi), %rdx
movq (JB_RSP*8)(%rdi), %rsp
/* Jump to saved PC */
jmpq *%rdx
.size _st_md_cxt_restore, .-_st_md_cxt_restore
/****************************************************************/
#endif

@ -105,35 +105,7 @@
(void) gettimeofday(&tv, NULL); \ (void) gettimeofday(&tv, NULL); \
return (tv.tv_sec * 1000000LL + tv.tv_usec) return (tv.tv_sec * 1000000LL + tv.tv_usec)
#if defined(__ia64__) #if defined(__mips__)
#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 #define MD_STACK_GROWS_DOWN
#define MD_INIT_CONTEXT(_thread, _sp, _main) \ #define MD_INIT_CONTEXT(_thread, _sp, _main) \
@ -142,7 +114,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 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.
@ -161,51 +133,7 @@
* 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(__i386__)
#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 #define MD_STACK_GROWS_DOWN
#define MD_USE_BUILTIN_SETJMP #define MD_USE_BUILTIN_SETJMP
@ -235,20 +163,6 @@
#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__)
#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 #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 */
@ -262,12 +176,14 @@
#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)
/* i386/x86_64 */
#define MD_SETJMP(env) _st_md_cxt_save(env) #define MD_SETJMP(env) _st_md_cxt_save(env)
#define MD_LONGJMP(env, val) _st_md_cxt_restore(env, val) #define MD_LONGJMP(env, val) _st_md_cxt_restore(env, val)
extern int _st_md_cxt_save(jmp_buf env); extern int _st_md_cxt_save(jmp_buf env);
extern void _st_md_cxt_restore(jmp_buf env, int val); extern void _st_md_cxt_restore(jmp_buf env, int val);
#else #else
/* arm/mips */
#define MD_SETJMP(env) setjmp(env) #define MD_SETJMP(env) setjmp(env)
#define MD_LONGJMP(env, val) longjmp(env, val) #define MD_LONGJMP(env, val) longjmp(env, val)
#endif #endif

Loading…
Cancel
Save