Skip to content

Commit

Permalink
use buildin setjmp/longjmp for arm. for #1
Browse files Browse the repository at this point in the history
  • Loading branch information
winlinvip committed Sep 3, 2016
1 parent 9a17dec commit 8d1b429
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
13 changes: 7 additions & 6 deletions md.h
Original file line number Diff line number Diff line change
Expand Up @@ -420,13 +420,14 @@

#elif defined(__arm__)
#define MD_STACK_GROWS_DOWN

#define MD_USE_BUILTIN_SETJMP

#ifndef JB_RSP
#define JB_RSP 8 // JB_RSP must be same as the index we save in jmpbuf
#endif
#define MD_GET_SP(_t) (_t)->context[0].__jmpbuf[JB_RSP]

#if defined(__GLIBC__) && __GLIBC__ >= 2
/* 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 */

#elif defined(__s390__)
#define MD_STACK_GROWS_DOWN
Expand Down
4 changes: 2 additions & 2 deletions sched.c
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ void st_thread_interrupt(_st_thread_t *thread)


/* Merge from https://github.com/michaeltalyansky/state-threads/commit/cce736426c2320ffec7c9820df49ee7a18ae638c */
#if defined(__arm__)
#if defined(__arm__) && !defined(MD_USE_BUILTIN_SETJMP) && __GLIBC_MINOR__ >= 19
extern unsigned long __pointer_chk_guard;
#define PTR_MANGLE(var) \
(var) = (__typeof (var)) ((unsigned long) (var) ^ __pointer_chk_guard)
Expand Down Expand Up @@ -595,7 +595,7 @@ _st_thread_t *st_thread_create(void *(*start)(void *arg), void *arg, int joinabl

#ifndef __ia64__
/* Merge from https://github.com/michaeltalyansky/state-threads/commit/cce736426c2320ffec7c9820df49ee7a18ae638c */
#if defined(__arm__)
#if defined(__arm__) && !defined(MD_USE_BUILTIN_SETJMP) && __GLIBC_MINOR__ >= 19
volatile void * lsp = PTR_MANGLE(stack->sp);
if (_setjmp ((thread)->context))
_st_thread_main();
Expand Down

0 comments on commit 8d1b429

Please sign in to comment.