Skip to content

Commit 9f7ed8f

Browse files
committed
fix #1, merge from michaeltalyansky, support ARM
1 parent 842bd4e commit 9f7ed8f

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ The branch [srs](https://github.com/ossrs/state-threads/tree/srs) will be patche
1313
- [x] Patch [st.osx.kqueue.patch](https://github.com/ossrs/srs/blob/2.0release/trunk/3rdparty/patches/3.st.osx.kqueue.patch), for osx.
1414
- [x] Patch [st.disable.examples.patch](https://github.com/ossrs/srs/blob/2.0release/trunk/3rdparty/patches/4.st.disable.examples.patch), for ubuntu.
1515
- [x] [Refine TAB of code](https://github.com/ossrs/state-threads/compare/c2001d30ca58f55d72a6cc6b9b6c70391eaf14db...d2101b26988b0e0db0aabc53ddf452068c1e2cbc).
16-
- [ ] Merge from [michaeltalyansky](https://github.com/michaeltalyansky/state-threads), support [ARM](https://github.com/ossrs/state-threads/issues/1).
16+
- [x] Merge from [michaeltalyansky](https://github.com/michaeltalyansky/state-threads), support [ARM](https://github.com/ossrs/state-threads/issues/1).
1717
- [ ] Merge from [toffaletti](https://github.com/toffaletti/state-threads), support [valgrind](https://github.com/ossrs/state-threads/issues/2) for ST.
1818

1919
## Usage

md.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,8 @@
422422
#define MD_STACK_GROWS_DOWN
423423

424424
#if defined(__GLIBC__) && __GLIBC__ >= 2
425-
#define MD_GET_SP(_t) (_t)->context[0].__jmpbuf[8] /*by SRS, 20=>8 for ARM*/
425+
/* Merge from https://github.com/michaeltalyansky/state-threads/commit/56554a5c425aee8e7a73782eae23d74d83c4120a */
426+
#define MD_GET_SP(_t) (_t)->context[0].__jmpbuf[8]
426427
#else
427428
#error "ARM/Linux pre-glibc2 not supported yet"
428429
#endif /* defined(__GLIBC__) && __GLIBC__ >= 2 */

sched.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,15 @@ void st_thread_interrupt(_st_thread_t *thread)
515515
}
516516

517517

518+
/* Merge from https://github.com/michaeltalyansky/state-threads/commit/cce736426c2320ffec7c9820df49ee7a18ae638c */
519+
#if defined(__arm__)
520+
extern unsigned long __pointer_chk_guard;
521+
#define PTR_MANGLE(var) \
522+
(var) = (__typeof (var)) ((unsigned long) (var) ^ __pointer_chk_guard)
523+
#define PTR_DEMANGLE(var) PTR_MANGLE (var)
524+
#endif
525+
526+
518527
_st_thread_t *st_thread_create(void *(*start)(void *arg), void *arg, int joinable, int stk_size)
519528
{
520529
_st_thread_t *thread;
@@ -585,7 +594,15 @@ _st_thread_t *st_thread_create(void *(*start)(void *arg), void *arg, int joinabl
585594
thread->arg = arg;
586595

587596
#ifndef __ia64__
588-
_ST_INIT_CONTEXT(thread, stack->sp, _st_thread_main);
597+
/* Merge from https://github.com/michaeltalyansky/state-threads/commit/cce736426c2320ffec7c9820df49ee7a18ae638c */
598+
#if defined(__arm__)
599+
volatile void * lsp = PTR_MANGLE(stack->sp);
600+
if (_setjmp ((thread)->context))
601+
_st_thread_main();
602+
(thread)->context[0].__jmpbuf[8] = (long) (lsp);
603+
#else
604+
_ST_INIT_CONTEXT(thread, stack->sp, _st_thread_main);
605+
#endif
589606
#else
590607
_ST_INIT_CONTEXT(thread, stack->sp, stack->bsp, _st_thread_main);
591608
#endif

0 commit comments

Comments
 (0)