正在显示
5 个修改的文件
包含
33 行增加
和
398 行删除
| @@ -252,10 +252,7 @@ if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then | @@ -252,10 +252,7 @@ if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then | ||
| 252 | ( | 252 | ( |
| 253 | rm -rf ${SRS_OBJS}/st-1.9 && cd ${SRS_OBJS} && | 253 | rm -rf ${SRS_OBJS}/st-1.9 && cd ${SRS_OBJS} && |
| 254 | unzip -q ../3rdparty/st-1.9.zip && cd st-1.9 && | 254 | unzip -q ../3rdparty/st-1.9.zip && cd st-1.9 && |
| 255 | - echo "we alaways patch the st, for we may build srs under arm directly" && | ||
| 256 | - echo "the 1.st.arm.patch is ok for x86 because it's only modify code under macro linux arm" && | ||
| 257 | - patch -p0 < ../../3rdparty/patches/1.st.arm.patch && | ||
| 258 | - make ${_ST_MAKE} && | 255 | + make ${_ST_MAKE} EXTRA_CFLAGS="-DMD_HAVE_EPOLL" && |
| 259 | cd .. && rm -rf st && ln -sf st-1.9/obj st && | 256 | cd .. && rm -rf st && ln -sf st-1.9/obj st && |
| 260 | cd .. && rm -f ${SRS_OBJS}/_flag.st.arm.tmp | 257 | cd .. && rm -f ${SRS_OBJS}/_flag.st.arm.tmp |
| 261 | ) | 258 | ) |
| @@ -33,25 +33,20 @@ void func0() | @@ -33,25 +33,20 @@ void func0() | ||
| 33 | }; | 33 | }; |
| 34 | */ | 34 | */ |
| 35 | #if defined(__amd64__) || defined(__x86_64__) | 35 | #if defined(__amd64__) || defined(__x86_64__) |
| 36 | - /** | ||
| 37 | - here, the __jmp_buf is 8*8=64 bytes | ||
| 38 | - # if __WORDSIZE == 64 | ||
| 39 | - typedef long int __jmp_buf[8]; | ||
| 40 | - */ | ||
| 41 | - /** | ||
| 42 | - the layout for setjmp of x86_64 | ||
| 43 | - # | ||
| 44 | - # The jmp_buf is assumed to contain the following, in order: | ||
| 45 | - # %rbx | ||
| 46 | - # %rsp (post-return) | ||
| 47 | - # %rbp | ||
| 48 | - # %r12 | ||
| 49 | - # %r13 | ||
| 50 | - # %r14 | ||
| 51 | - # %r15 | ||
| 52 | - # <return address> | ||
| 53 | - # | 36 | + // http://ftp.gnu.org/gnu/glibc/glibc-2.12.2.tar.xz |
| 37 | + // http://ftp.gnu.org/gnu/glibc/glibc-2.12.1.tar.gz | ||
| 38 | + /* | ||
| 39 | + * Starting with glibc 2.4, JB_SP definitions are not public anymore. | ||
| 40 | + * They, however, can still be found in glibc source tree in | ||
| 41 | + * architecture-specific "jmpbuf-offsets.h" files. | ||
| 42 | + * Most importantly, the content of jmp_buf is mangled by setjmp to make | ||
| 43 | + * it completely opaque (the mangling can be disabled by setting the | ||
| 44 | + * LD_POINTER_GUARD environment variable before application execution). | ||
| 45 | + * Therefore we will use built-in _st_md_cxt_save/_st_md_cxt_restore | ||
| 46 | + * functions as a setjmp/longjmp replacement wherever they are available | ||
| 47 | + * unless USE_LIBC_SETJMP is defined. | ||
| 54 | */ | 48 | */ |
| 49 | + // for glibc 2.4+, it's not possible to get and set the sp in jmp_buf | ||
| 55 | register long int rsp0 asm("rsp"); | 50 | register long int rsp0 asm("rsp"); |
| 56 | 51 | ||
| 57 | int ret = setjmp(env_func1); | 52 | int ret = setjmp(env_func1); |
| @@ -64,7 +59,9 @@ void func0() | @@ -64,7 +59,9 @@ void func0() | ||
| 64 | printf("\n"); | 59 | printf("\n"); |
| 65 | 60 | ||
| 66 | func1(); | 61 | func1(); |
| 67 | -#else | 62 | +#endif |
| 63 | + | ||
| 64 | +#if defined(__arm__) | ||
| 68 | /** | 65 | /** |
| 69 | /usr/arm-linux-gnueabi/include/bits/setjmp.h | 66 | /usr/arm-linux-gnueabi/include/bits/setjmp.h |
| 70 | #ifndef _ASM | 67 | #ifndef _ASM |
| @@ -115,13 +112,18 @@ void func0() | @@ -115,13 +112,18 @@ void func0() | ||
| 115 | #endif | 112 | #endif |
| 116 | } | 113 | } |
| 117 | 114 | ||
| 115 | +extern uintptr_t _jmpbuf_sp (__jmp_buf regs); | ||
| 118 | int main(int argc, char** argv) { | 116 | int main(int argc, char** argv) { |
| 119 | #if defined(__amd64__) || defined(__x86_64__) | 117 | #if defined(__amd64__) || defined(__x86_64__) |
| 120 | - printf("x86_64 sizeof(long int)=%d, sizeof(long)=%d, sizeof(int)=%d, __WORDSIZE=%d\n", | ||
| 121 | - (int)sizeof(long int), (int)sizeof(long), (int)sizeof(int), (int)__WORDSIZE); | 118 | + printf("x86_64 sizeof(long int)=%d, sizeof(long)=%d, " |
| 119 | + "sizeof(int)=%d, __WORDSIZE=%d, __GLIBC__=%d, __GLIBC_MINOR__=%d\n", | ||
| 120 | + (int)sizeof(long int), (int)sizeof(long), (int)sizeof(int), | ||
| 121 | + (int)__WORDSIZE, (int)__GLIBC__, (int)__GLIBC_MINOR__); | ||
| 122 | #else | 122 | #else |
| 123 | - printf("arm sizeof(long int)=%d, sizeof(long)=%d, sizeof(int)=%d\n", | ||
| 124 | - (int)sizeof(long int), (int)sizeof(long), (int)sizeof(int)); | 123 | + printf("arm sizeof(long int)=%d, sizeof(long)=%d, " |
| 124 | + "sizeof(int)=%d, __GLIBC__=%d,__GLIBC_MINOR__=%d\n", | ||
| 125 | + (int)sizeof(long int), (int)sizeof(long), (int)sizeof(int), | ||
| 126 | + (int)__GLIBC__, (int)__GLIBC_MINOR__); | ||
| 125 | #endif | 127 | #endif |
| 126 | 128 | ||
| 127 | func0(); | 129 | func0(); |
| @@ -51,7 +51,7 @@ EXTRA_OBJS = $(TARGETDIR)/md.o | @@ -51,7 +51,7 @@ EXTRA_OBJS = $(TARGETDIR)/md.o | ||
| 51 | 51 | ||
| 52 | CFLAGS = | 52 | CFLAGS = |
| 53 | OTHER_FLAGS += -Wall -g -O0 | 53 | OTHER_FLAGS += -Wall -g -O0 |
| 54 | -DEFINES = -D$(OS) -DDEBUG -DMD_HAVE_EPOLL | 54 | +DEFINES = -D$(OS) -DDEBUG -DMD_HAVE_EPOLL -DMALLOC_STACK |
| 55 | 55 | ||
| 56 | ########################## | 56 | ########################## |
| 57 | # Other possible defines: | 57 | # Other possible defines: |
trunk/research/st/md.S
100644 → 100755
| @@ -3,289 +3,9 @@ | @@ -3,289 +3,9 @@ | ||
| 3 | * All Rights Reserved. | 3 | * All Rights Reserved. |
| 4 | */ | 4 | */ |
| 5 | 5 | ||
| 6 | -#if defined(__ia64__) | ||
| 7 | - | ||
| 8 | -/* | ||
| 9 | - * The internal __jmp_buf layout is different from one used | ||
| 10 | - * by setjmp()/longjmp(). | ||
| 11 | - * | ||
| 12 | - * Offset Description | ||
| 13 | - * ------ ----------- | ||
| 14 | - * 0x000 stack pointer (r12) | ||
| 15 | - * 0x008 gp (r1) | ||
| 16 | - * 0x010 caller's unat | ||
| 17 | - * 0x018 fpsr | ||
| 18 | - * 0x020 r4 | ||
| 19 | - * 0x028 r5 | ||
| 20 | - * 0x030 r6 | ||
| 21 | - * 0x038 r7 | ||
| 22 | - * 0x040 rp (b0) | ||
| 23 | - * 0x048 b1 | ||
| 24 | - * 0x050 b2 | ||
| 25 | - * 0x058 b3 | ||
| 26 | - * 0x060 b4 | ||
| 27 | - * 0x068 b5 | ||
| 28 | - * 0x070 ar.pfs | ||
| 29 | - * 0x078 ar.lc | ||
| 30 | - * 0x080 pr | ||
| 31 | - * 0x088 ar.bsp | ||
| 32 | - * 0x090 ar.unat | ||
| 33 | - * 0x098 &__jmp_buf | ||
| 34 | - * 0x0a0 ar.rsc | ||
| 35 | - * 0x0a8 ar.rnat | ||
| 36 | - * 0x0b0 f2 | ||
| 37 | - * 0x0c0 f3 | ||
| 38 | - * 0x0d0 f4 | ||
| 39 | - * 0x0e0 f5 | ||
| 40 | - * 0x0f0 f16 | ||
| 41 | - * 0x100 f17 | ||
| 42 | - * 0x110 f18 | ||
| 43 | - * 0x120 f19 | ||
| 44 | - * 0x130 f20 | ||
| 45 | - * 0x130 f21 | ||
| 46 | - * 0x140 f22 | ||
| 47 | - * 0x150 f23 | ||
| 48 | - * 0x160 f24 | ||
| 49 | - * 0x170 f25 | ||
| 50 | - * 0x180 f26 | ||
| 51 | - * 0x190 f27 | ||
| 52 | - * 0x1a0 f28 | ||
| 53 | - * 0x1b0 f29 | ||
| 54 | - * 0x1c0 f30 | ||
| 55 | - * 0x1d0 f31 | ||
| 56 | - * | ||
| 57 | - * Note that the address of __jmp_buf is saved but not used: we assume | ||
| 58 | - * that the jmp_buf data structure is never moved around in memory. | ||
| 59 | - */ | ||
| 60 | - | ||
| 61 | -/* | ||
| 62 | - * Implemented according to "IA-64 Software Conventions and Runtime | ||
| 63 | - * Architecture Guide", Chapter 10: "Context Management". | ||
| 64 | - */ | ||
| 65 | - | ||
| 66 | - .text | ||
| 67 | - .psr abi64 | ||
| 68 | - .psr lsb | ||
| 69 | - .lsb | ||
| 70 | - | ||
| 71 | - /* _st_md_cxt_save(__jmp_buf env) */ | ||
| 72 | - .align 32 | ||
| 73 | - .global _st_md_cxt_save | ||
| 74 | - .proc _st_md_cxt_save | ||
| 75 | -_st_md_cxt_save: | ||
| 76 | - alloc r14 = ar.pfs,1,0,0,0 | ||
| 77 | - mov r16 = ar.unat | ||
| 78 | - ;; | ||
| 79 | - mov r17 = ar.fpsr | ||
| 80 | - mov r2 = in0 | ||
| 81 | - add r3 = 8,in0 | ||
| 82 | - ;; | ||
| 83 | - st8.spill.nta [r2] = sp,16 // r12 (sp) | ||
| 84 | - ;; | ||
| 85 | - st8.spill.nta [r3] = gp,16 // r1 (gp) | ||
| 86 | - ;; | ||
| 87 | - st8.nta [r2] = r16,16 // save caller's unat | ||
| 88 | - st8.nta [r3] = r17,16 // save fpsr | ||
| 89 | - add r8 = 0xb0,in0 | ||
| 90 | - ;; | ||
| 91 | - st8.spill.nta [r2] = r4,16 // r4 | ||
| 92 | - ;; | ||
| 93 | - st8.spill.nta [r3] = r5,16 // r5 | ||
| 94 | - add r9 = 0xc0,in0 | ||
| 95 | - ;; | ||
| 96 | - stf.spill.nta [r8] = f2,32 | ||
| 97 | - stf.spill.nta [r9] = f3,32 | ||
| 98 | - mov r15 = rp | ||
| 99 | - ;; | ||
| 100 | - stf.spill.nta [r8] = f4,32 | ||
| 101 | - stf.spill.nta [r9] = f5,32 | ||
| 102 | - mov r17 = b1 | ||
| 103 | - ;; | ||
| 104 | - stf.spill.nta [r8] = f16,32 | ||
| 105 | - stf.spill.nta [r9] = f17,32 | ||
| 106 | - mov r18 = b2 | ||
| 107 | - ;; | ||
| 108 | - stf.spill.nta [r8] = f18,32 | ||
| 109 | - stf.spill.nta [r9] = f19,32 | ||
| 110 | - mov r19 = b3 | ||
| 111 | - ;; | ||
| 112 | - stf.spill.nta [r8] = f20,32 | ||
| 113 | - stf.spill.nta [r9] = f21,32 | ||
| 114 | - mov r20 = b4 | ||
| 115 | - ;; | ||
| 116 | - stf.spill.nta [r8] = f22,32 | ||
| 117 | - stf.spill.nta [r9] = f23,32 | ||
| 118 | - mov r21 = b5 | ||
| 119 | - ;; | ||
| 120 | - stf.spill.nta [r8] = f24,32 | ||
| 121 | - stf.spill.nta [r9] = f25,32 | ||
| 122 | - mov r22 = ar.lc | ||
| 123 | - ;; | ||
| 124 | - stf.spill.nta [r8] = f26,32 | ||
| 125 | - stf.spill.nta [r9] = f27,32 | ||
| 126 | - mov r24 = pr | ||
| 127 | - ;; | ||
| 128 | - stf.spill.nta [r8] = f28,32 | ||
| 129 | - stf.spill.nta [r9] = f29,32 | ||
| 130 | - ;; | ||
| 131 | - stf.spill.nta [r8] = f30 | ||
| 132 | - stf.spill.nta [r9] = f31 | ||
| 133 | - | ||
| 134 | - st8.spill.nta [r2] = r6,16 // r6 | ||
| 135 | - ;; | ||
| 136 | - st8.spill.nta [r3] = r7,16 // r7 | ||
| 137 | - ;; | ||
| 138 | - mov r23 = ar.bsp | ||
| 139 | - mov r25 = ar.unat | ||
| 140 | - | ||
| 141 | - st8.nta [r2] = r15,16 // b0 | ||
| 142 | - st8.nta [r3] = r17,16 // b1 | ||
| 143 | - ;; | ||
| 144 | - st8.nta [r2] = r18,16 // b2 | ||
| 145 | - st8.nta [r3] = r19,16 // b3 | ||
| 146 | - mov r26 = ar.rsc | ||
| 147 | - ;; | ||
| 148 | - st8.nta [r2] = r20,16 // b4 | ||
| 149 | - st8.nta [r3] = r21,16 // b5 | ||
| 150 | - ;; | ||
| 151 | - st8.nta [r2] = r14,16 // ar.pfs | ||
| 152 | - st8.nta [r3] = r22,16 // ar.lc | ||
| 153 | - ;; | ||
| 154 | - st8.nta [r2] = r24,16 // pr | ||
| 155 | - st8.nta [r3] = r23,16 // ar.bsp | ||
| 156 | - ;; | ||
| 157 | - st8.nta [r2] = r25,16 // ar.unat | ||
| 158 | - st8.nta [r3] = in0,16 // &__jmp_buf (just in case) | ||
| 159 | - ;; | ||
| 160 | - st8.nta [r2] = r26 // ar.rsc | ||
| 161 | - ;; | ||
| 162 | - flushrs // flush dirty regs to backing store | ||
| 163 | - ;; | ||
| 164 | - and r27 = ~0x3,r26 // clear ar.rsc.mode | ||
| 165 | - ;; | ||
| 166 | - mov ar.rsc = r27 // put RSE in enforced lazy mode | ||
| 167 | - ;; | ||
| 168 | - mov r28 = ar.rnat | ||
| 169 | - ;; | ||
| 170 | - st8.nta [r3] = r28 // ar.rnat | ||
| 171 | - mov ar.rsc = r26 // restore ar.rsc | ||
| 172 | - ;; | ||
| 173 | - mov r8 = 0 | ||
| 174 | - br.ret.sptk.few b0 | ||
| 175 | - .endp _st_md_cxt_save | ||
| 176 | - | ||
| 177 | - | ||
| 178 | -/****************************************************************/ | ||
| 179 | - | ||
| 180 | - /* _st_md_cxt_restore(__jmp_buf env, int val) */ | ||
| 181 | - .global _st_md_cxt_restore | ||
| 182 | - .proc _st_md_cxt_restore | ||
| 183 | -_st_md_cxt_restore: | ||
| 184 | - alloc r8 = ar.pfs,2,0,0,0 | ||
| 185 | - add r2 = 0x88,in0 // r2 <- &jmpbuf.ar_bsp | ||
| 186 | - mov r16 = ar.rsc | ||
| 187 | - ;; | ||
| 188 | - flushrs // flush dirty regs to backing store | ||
| 189 | - ;; | ||
| 190 | - and r17 = ~0x3,r16 // clear ar.rsc.mode | ||
| 191 | - ;; | ||
| 192 | - mov ar.rsc = r17 // put RSE in enforced lazy mode | ||
| 193 | - ;; | ||
| 194 | - invala // invalidate the ALAT | ||
| 195 | - ;; | ||
| 196 | - ld8 r23 = [r2],8 // r23 <- jmpbuf.ar_bsp | ||
| 197 | - ;; | ||
| 198 | - mov ar.bspstore = r23 // write BSPSTORE | ||
| 199 | - ld8 r25 = [r2],24 // r25 <- jmpbuf.ar_unat | ||
| 200 | - ;; | ||
| 201 | - ld8 r26 = [r2],-8 // r26 <- jmpbuf.ar_rnat | ||
| 202 | - ;; | ||
| 203 | - mov ar.rnat = r26 // write RNAT | ||
| 204 | - ld8 r27 = [r2] // r27 <- jmpbuf.ar_rsc | ||
| 205 | - ;; | ||
| 206 | - mov ar.rsc = r27 // write RSE control | ||
| 207 | - mov r2 = in0 | ||
| 208 | - ;; | ||
| 209 | - mov ar.unat = r25 // write ar.unat | ||
| 210 | - add r3 = 8,in0 | ||
| 211 | - ;; | ||
| 212 | - ld8.fill.nta sp = [r2],16 // r12 (sp) | ||
| 213 | - ld8.fill.nta gp = [r3],16 // r1 (gp) | ||
| 214 | - ;; | ||
| 215 | - ld8.nta r16 = [r2],16 // caller's unat | ||
| 216 | - ld8.nta r17 = [r3],16 // fpsr | ||
| 217 | - ;; | ||
| 218 | - ld8.fill.nta r4 = [r2],16 // r4 | ||
| 219 | - ld8.fill.nta r5 = [r3],16 // r5 | ||
| 220 | - ;; | ||
| 221 | - ld8.fill.nta r6 = [r2],16 // r6 | ||
| 222 | - ld8.fill.nta r7 = [r3],16 // r7 | ||
| 223 | - ;; | ||
| 224 | - mov ar.unat = r16 // restore caller's unat | ||
| 225 | - mov ar.fpsr = r17 // restore fpsr | ||
| 226 | - ;; | ||
| 227 | - ld8.nta r16 = [r2],16 // b0 | ||
| 228 | - ld8.nta r17 = [r3],16 // b1 | ||
| 229 | - ;; | ||
| 230 | - ld8.nta r18 = [r2],16 // b2 | ||
| 231 | - ld8.nta r19 = [r3],16 // b3 | ||
| 232 | - ;; | ||
| 233 | - ld8.nta r20 = [r2],16 // b4 | ||
| 234 | - ld8.nta r21 = [r3],16 // b5 | ||
| 235 | - ;; | ||
| 236 | - ld8.nta r11 = [r2],16 // ar.pfs | ||
| 237 | - ld8.nta r22 = [r3],72 // ar.lc | ||
| 238 | - ;; | ||
| 239 | - ld8.nta r24 = [r2],48 // pr | ||
| 240 | - mov b0 = r16 | ||
| 241 | - ;; | ||
| 242 | - ldf.fill.nta f2 = [r2],32 | ||
| 243 | - ldf.fill.nta f3 = [r3],32 | ||
| 244 | - mov b1 = r17 | ||
| 245 | - ;; | ||
| 246 | - ldf.fill.nta f4 = [r2],32 | ||
| 247 | - ldf.fill.nta f5 = [r3],32 | ||
| 248 | - mov b2 = r18 | ||
| 249 | - ;; | ||
| 250 | - ldf.fill.nta f16 = [r2],32 | ||
| 251 | - ldf.fill.nta f17 = [r3],32 | ||
| 252 | - mov b3 = r19 | ||
| 253 | - ;; | ||
| 254 | - ldf.fill.nta f18 = [r2],32 | ||
| 255 | - ldf.fill.nta f19 = [r3],32 | ||
| 256 | - mov b4 = r20 | ||
| 257 | - ;; | ||
| 258 | - ldf.fill.nta f20 = [r2],32 | ||
| 259 | - ldf.fill.nta f21 = [r3],32 | ||
| 260 | - mov b5 = r21 | ||
| 261 | - ;; | ||
| 262 | - ldf.fill.nta f22 = [r2],32 | ||
| 263 | - ldf.fill.nta f23 = [r3],32 | ||
| 264 | - mov ar.lc = r22 | ||
| 265 | - ;; | ||
| 266 | - ldf.fill.nta f24 = [r2],32 | ||
| 267 | - ldf.fill.nta f25 = [r3],32 | ||
| 268 | - cmp.eq p6,p7 = 0,in1 | ||
| 269 | - ;; | ||
| 270 | - ldf.fill.nta f26 = [r2],32 | ||
| 271 | - ldf.fill.nta f27 = [r3],32 | ||
| 272 | - mov ar.pfs = r11 | ||
| 273 | - ;; | ||
| 274 | - ldf.fill.nta f28 = [r2],32 | ||
| 275 | - ldf.fill.nta f29 = [r3],32 | ||
| 276 | - ;; | ||
| 277 | - ldf.fill.nta f30 = [r2] | ||
| 278 | - ldf.fill.nta f31 = [r3] | ||
| 279 | -(p6) mov r8 = 1 | ||
| 280 | -(p7) mov r8 = in1 | ||
| 281 | - | ||
| 282 | - mov pr = r24,-1 | ||
| 283 | - br.ret.sptk.few b0 | ||
| 284 | - .endp _st_md_cxt_restore | ||
| 285 | - | ||
| 286 | /****************************************************************/ | 6 | /****************************************************************/ |
| 287 | 7 | ||
| 288 | -#elif defined(__i386__) | 8 | +#if defined(__i386__) |
| 289 | 9 | ||
| 290 | /* | 10 | /* |
| 291 | * Internal __jmp_buf layout | 11 | * Internal __jmp_buf layout |
| @@ -105,35 +105,7 @@ | @@ -105,35 +105,7 @@ | ||
| 105 | (void) gettimeofday(&tv, NULL); \ | 105 | (void) gettimeofday(&tv, NULL); \ |
| 106 | return (tv.tv_sec * 1000000LL + tv.tv_usec) | 106 | return (tv.tv_sec * 1000000LL + tv.tv_usec) |
| 107 | 107 | ||
| 108 | -#if defined(__ia64__) | ||
| 109 | - #define MD_STACK_GROWS_DOWN | ||
| 110 | - | ||
| 111 | - /* | ||
| 112 | - * IA-64 architecture. Besides traditional memory call stack, IA-64 | ||
| 113 | - * uses general register stack. Thus each thread needs a backing store | ||
| 114 | - * for register stack in addition to memory stack. Standard | ||
| 115 | - * setjmp()/longjmp() cannot be used for thread context switching | ||
| 116 | - * because their implementation implicitly assumes that only one | ||
| 117 | - * register stack exists. | ||
| 118 | - */ | ||
| 119 | - #ifdef USE_LIBC_SETJMP | ||
| 120 | - #undef USE_LIBC_SETJMP | ||
| 121 | - #endif | ||
| 122 | - #define MD_USE_BUILTIN_SETJMP | ||
| 123 | - | ||
| 124 | - #define MD_STACK_PAD_SIZE 128 | ||
| 125 | - /* Last register stack frame must be preserved */ | ||
| 126 | - #define MD_INIT_CONTEXT(_thread, _sp, _bsp, _main) \ | ||
| 127 | - ST_BEGIN_MACRO \ | ||
| 128 | - if (MD_SETJMP((_thread)->context)) \ | ||
| 129 | - _main(); \ | ||
| 130 | - memcpy((char *)(_bsp) - MD_STACK_PAD_SIZE, \ | ||
| 131 | - (char *)(_thread)->context[0].__jmpbuf[17] - MD_STACK_PAD_SIZE, \ | ||
| 132 | - MD_STACK_PAD_SIZE); \ | ||
| 133 | - (_thread)->context[0].__jmpbuf[0] = (long) (_sp); \ | ||
| 134 | - (_thread)->context[0].__jmpbuf[17] = (long) (_bsp); \ | ||
| 135 | - ST_END_MACRO | ||
| 136 | -#elif defined(__mips__) | 108 | +#if defined(__mips__) |
| 137 | #define MD_STACK_GROWS_DOWN | 109 | #define MD_STACK_GROWS_DOWN |
| 138 | 110 | ||
| 139 | #define MD_INIT_CONTEXT(_thread, _sp, _main) \ | 111 | #define MD_INIT_CONTEXT(_thread, _sp, _main) \ |
| @@ -142,7 +114,7 @@ | @@ -142,7 +114,7 @@ | ||
| 142 | _thread->context[0].__jmpbuf[0].__pc = (__ptr_t) _main; \ | 114 | _thread->context[0].__jmpbuf[0].__pc = (__ptr_t) _main; \ |
| 143 | _thread->context[0].__jmpbuf[0].__sp = _sp; \ | 115 | _thread->context[0].__jmpbuf[0].__sp = _sp; \ |
| 144 | ST_END_MACRO | 116 | ST_END_MACRO |
| 145 | -#else /* Not IA-64 or mips */ | 117 | +#else /* Not or mips */ |
| 146 | /* | 118 | /* |
| 147 | * On linux, there are a few styles of jmpbuf format. These vary based | 119 | * On linux, there are a few styles of jmpbuf format. These vary based |
| 148 | * on architecture/glibc combination. | 120 | * on architecture/glibc combination. |
| @@ -161,51 +133,7 @@ | @@ -161,51 +133,7 @@ | ||
| 161 | * functions as a setjmp/longjmp replacement wherever they are available | 133 | * functions as a setjmp/longjmp replacement wherever they are available |
| 162 | * unless USE_LIBC_SETJMP is defined. | 134 | * unless USE_LIBC_SETJMP is defined. |
| 163 | */ | 135 | */ |
| 164 | - #if defined(__powerpc__) | ||
| 165 | - #define MD_STACK_GROWS_DOWN | ||
| 166 | - | ||
| 167 | - #if (__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) | ||
| 168 | - #ifndef JB_GPR1 | ||
| 169 | - #define JB_GPR1 0 | ||
| 170 | - #endif | ||
| 171 | - #define MD_GET_SP(_t) (_t)->context[0].__jmpbuf[JB_GPR1] | ||
| 172 | - #else | ||
| 173 | - /* not an error but certainly cause for caution */ | ||
| 174 | - #error "Untested use of old glibc on powerpc" | ||
| 175 | - #define MD_GET_SP(_t) (_t)->context[0].__jmpbuf[0].__misc[0] | ||
| 176 | - #endif /* glibc 2.1 or later */ | ||
| 177 | - #elif defined(__alpha) | ||
| 178 | - #define MD_STACK_GROWS_DOWN | ||
| 179 | - | ||
| 180 | - #if defined(__GLIBC__) && __GLIBC__ >= 2 | ||
| 181 | - #ifndef JB_SP | ||
| 182 | - #define JB_SP 8 | ||
| 183 | - #endif | ||
| 184 | - #define MD_GET_SP(_t) (_t)->context[0].__jmpbuf[JB_SP] | ||
| 185 | - #else | ||
| 186 | - /* not an error but certainly cause for caution */ | ||
| 187 | - #error "Untested use of old glibc on alpha" | ||
| 188 | - #define MD_GET_SP(_t) (_t)->context[0].__jmpbuf[0].__sp | ||
| 189 | - #endif | ||
| 190 | - #elif defined(__mc68000__) | ||
| 191 | - #define MD_STACK_GROWS_DOWN | ||
| 192 | - | ||
| 193 | - /* m68k still uses old style sigjmp_buf */ | ||
| 194 | - #define MD_GET_SP(_t) (_t)->context[0].__jmpbuf[0].__sp | ||
| 195 | - #elif defined(__sparc__) | ||
| 196 | - #define MD_STACK_GROWS_DOWN | ||
| 197 | - | ||
| 198 | - #if defined(__GLIBC__) && __GLIBC__ >= 2 | ||
| 199 | - #ifndef JB_SP | ||
| 200 | - #define JB_SP 0 | ||
| 201 | - #endif | ||
| 202 | - #define MD_GET_SP(_t) (_t)->context[0].__jmpbuf[JB_SP] | ||
| 203 | - #else | ||
| 204 | - /* not an error but certainly cause for caution */ | ||
| 205 | - #error "Untested use of old glic on sparc -- also using odd mozilla derived __fp" | ||
| 206 | - #define MD_GET_SP(_t) (_t)->context[0].__jmpbuf[0].__fp | ||
| 207 | - #endif | ||
| 208 | - #elif defined(__i386__) | 136 | + #if defined(__i386__) |
| 209 | #define MD_STACK_GROWS_DOWN | 137 | #define MD_STACK_GROWS_DOWN |
| 210 | #define MD_USE_BUILTIN_SETJMP | 138 | #define MD_USE_BUILTIN_SETJMP |
| 211 | 139 | ||
| @@ -235,20 +163,6 @@ | @@ -235,20 +163,6 @@ | ||
| 235 | #else | 163 | #else |
| 236 | #error "ARM/Linux pre-glibc2 not supported yet" | 164 | #error "ARM/Linux pre-glibc2 not supported yet" |
| 237 | #endif /* defined(__GLIBC__) && __GLIBC__ >= 2 */ | 165 | #endif /* defined(__GLIBC__) && __GLIBC__ >= 2 */ |
| 238 | - #elif defined(__s390__) | ||
| 239 | - #define MD_STACK_GROWS_DOWN | ||
| 240 | - | ||
| 241 | - /* There is no JB_SP in glibc at this time. (glibc 2.2.5) | ||
| 242 | - */ | ||
| 243 | - #define MD_GET_SP(_t) (_t)->context[0].__jmpbuf[0].__gregs[9] | ||
| 244 | - #elif defined(__hppa__) | ||
| 245 | - #define MD_STACK_GROWS_UP | ||
| 246 | - | ||
| 247 | - /* yes, this is gross, unfortunately at the moment (2002/08/01) there is | ||
| 248 | - * a bug in hppa's glibc header definition for JB_SP, so we can't | ||
| 249 | - * use that... | ||
| 250 | - */ | ||
| 251 | - #define MD_GET_SP(_t) (*(long *)(((char *)&(_t)->context[0].__jmpbuf[0]) + 76)) | ||
| 252 | #else | 166 | #else |
| 253 | #error "Unknown CPU architecture" | 167 | #error "Unknown CPU architecture" |
| 254 | #endif /* Cases with common MD_INIT_CONTEXT and different SP locations */ | 168 | #endif /* Cases with common MD_INIT_CONTEXT and different SP locations */ |
| @@ -262,12 +176,14 @@ | @@ -262,12 +176,14 @@ | ||
| 262 | #endif /* Cases with different MD_INIT_CONTEXT */ | 176 | #endif /* Cases with different MD_INIT_CONTEXT */ |
| 263 | 177 | ||
| 264 | #if defined(MD_USE_BUILTIN_SETJMP) && !defined(USE_LIBC_SETJMP) | 178 | #if defined(MD_USE_BUILTIN_SETJMP) && !defined(USE_LIBC_SETJMP) |
| 179 | + /* i386/x86_64 */ | ||
| 265 | #define MD_SETJMP(env) _st_md_cxt_save(env) | 180 | #define MD_SETJMP(env) _st_md_cxt_save(env) |
| 266 | #define MD_LONGJMP(env, val) _st_md_cxt_restore(env, val) | 181 | #define MD_LONGJMP(env, val) _st_md_cxt_restore(env, val) |
| 267 | 182 | ||
| 268 | extern int _st_md_cxt_save(jmp_buf env); | 183 | extern int _st_md_cxt_save(jmp_buf env); |
| 269 | extern void _st_md_cxt_restore(jmp_buf env, int val); | 184 | extern void _st_md_cxt_restore(jmp_buf env, int val); |
| 270 | #else | 185 | #else |
| 186 | + /* arm/mips */ | ||
| 271 | #define MD_SETJMP(env) setjmp(env) | 187 | #define MD_SETJMP(env) setjmp(env) |
| 272 | #define MD_LONGJMP(env, val) longjmp(env, val) | 188 | #define MD_LONGJMP(env, val) longjmp(env, val) |
| 273 | #endif | 189 | #endif |
-
请 注册 或 登录 后发表评论