Skip to content

Commit

Permalink
fix #1, merge from michaeltalyansky, support ARM
Browse files Browse the repository at this point in the history
  • Loading branch information
winlinvip committed Sep 3, 2016
1 parent 842bd4e commit 9f7ed8f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ The branch [srs](https://github.com/ossrs/state-threads/tree/srs) will be patche
- [x] Patch [st.osx.kqueue.patch](https://github.com/ossrs/srs/blob/2.0release/trunk/3rdparty/patches/3.st.osx.kqueue.patch), for osx.
- [x] Patch [st.disable.examples.patch](https://github.com/ossrs/srs/blob/2.0release/trunk/3rdparty/patches/4.st.disable.examples.patch), for ubuntu.
- [x] [Refine TAB of code](https://github.com/ossrs/state-threads/compare/c2001d30ca58f55d72a6cc6b9b6c70391eaf14db...d2101b26988b0e0db0aabc53ddf452068c1e2cbc).
- [ ] Merge from [michaeltalyansky](https://github.com/michaeltalyansky/state-threads), support [ARM](https://github.com/ossrs/state-threads/issues/1).
- [x] Merge from [michaeltalyansky](https://github.com/michaeltalyansky/state-threads), support [ARM](https://github.com/ossrs/state-threads/issues/1).
- [ ] Merge from [toffaletti](https://github.com/toffaletti/state-threads), support [valgrind](https://github.com/ossrs/state-threads/issues/2) for ST.

## Usage
Expand Down
3 changes: 2 additions & 1 deletion md.h
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,8 @@
#define MD_STACK_GROWS_DOWN

#if defined(__GLIBC__) && __GLIBC__ >= 2
#define MD_GET_SP(_t) (_t)->context[0].__jmpbuf[8] /*by SRS, 20=>8 for ARM*/
/* Merge from https://github.com/michaeltalyansky/state-threads/commit/56554a5c425aee8e7a73782eae23d74d83c4120a */
#define MD_GET_SP(_t) (_t)->context[0].__jmpbuf[8]
#else
#error "ARM/Linux pre-glibc2 not supported yet"
#endif /* defined(__GLIBC__) && __GLIBC__ >= 2 */
Expand Down
19 changes: 18 additions & 1 deletion sched.c
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,15 @@ void st_thread_interrupt(_st_thread_t *thread)
}


/* Merge from https://github.com/michaeltalyansky/state-threads/commit/cce736426c2320ffec7c9820df49ee7a18ae638c */
#if defined(__arm__)
extern unsigned long __pointer_chk_guard;
#define PTR_MANGLE(var) \
(var) = (__typeof (var)) ((unsigned long) (var) ^ __pointer_chk_guard)
#define PTR_DEMANGLE(var) PTR_MANGLE (var)
#endif


_st_thread_t *st_thread_create(void *(*start)(void *arg), void *arg, int joinable, int stk_size)
{
_st_thread_t *thread;
Expand Down Expand Up @@ -585,7 +594,15 @@ _st_thread_t *st_thread_create(void *(*start)(void *arg), void *arg, int joinabl
thread->arg = arg;

#ifndef __ia64__
_ST_INIT_CONTEXT(thread, stack->sp, _st_thread_main);
/* Merge from https://github.com/michaeltalyansky/state-threads/commit/cce736426c2320ffec7c9820df49ee7a18ae638c */
#if defined(__arm__)
volatile void * lsp = PTR_MANGLE(stack->sp);
if (_setjmp ((thread)->context))
_st_thread_main();
(thread)->context[0].__jmpbuf[8] = (long) (lsp);
#else
_ST_INIT_CONTEXT(thread, stack->sp, _st_thread_main);
#endif
#else
_ST_INIT_CONTEXT(thread, stack->sp, stack->bsp, _st_thread_main);
#endif
Expand Down

0 comments on commit 9f7ed8f

Please sign in to comment.