* configure.in: check ucontext.h.
* eval.c: use getcontext/setcontext() instead of setjmp/longjmp() on ia64 or with native thread enabled. [ruby-core:01932] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5180 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
47c59bb62b
commit
9fdbc41973
@ -1,3 +1,10 @@
|
|||||||
|
Sat Dec 13 09:01:23 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* configure.in: check ucontext.h.
|
||||||
|
|
||||||
|
* eval.c: use getcontext/setcontext() instead of setjmp/longjmp()
|
||||||
|
on ia64 or with native thread enabled. [ruby-core:01932]
|
||||||
|
|
||||||
Sat Dec 13 03:09:14 2003 why the lucky stiff <why@ruby-lang.org>
|
Sat Dec 13 03:09:14 2003 why the lucky stiff <why@ruby-lang.org>
|
||||||
|
|
||||||
* lib/yaml/rubytypes.rb: anonymous struct fix. [ruby-core:01946]
|
* lib/yaml/rubytypes.rb: anonymous struct fix. [ruby-core:01946]
|
||||||
|
@ -364,7 +364,8 @@ AC_HEADER_SYS_WAIT
|
|||||||
AC_CHECK_HEADERS(stdlib.h string.h unistd.h limits.h sys/file.h sys/ioctl.h\
|
AC_CHECK_HEADERS(stdlib.h string.h unistd.h limits.h sys/file.h sys/ioctl.h\
|
||||||
fcntl.h sys/fcntl.h sys/select.h sys/time.h sys/times.h sys/param.h\
|
fcntl.h sys/fcntl.h sys/select.h sys/time.h sys/times.h sys/param.h\
|
||||||
syscall.h pwd.h grp.h a.out.h utime.h memory.h direct.h sys/resource.h \
|
syscall.h pwd.h grp.h a.out.h utime.h memory.h direct.h sys/resource.h \
|
||||||
sys/mkdev.h sys/utime.h netinet/in_systm.h float.h ieeefp.h pthread.h)
|
sys/mkdev.h sys/utime.h netinet/in_systm.h float.h ieeefp.h pthread.h \
|
||||||
|
ucontext.h)
|
||||||
|
|
||||||
dnl Checks for typedefs, structures, and compiler characteristics.
|
dnl Checks for typedefs, structures, and compiler characteristics.
|
||||||
AC_TYPE_UID_T
|
AC_TYPE_UID_T
|
||||||
|
55
eval.c
55
eval.c
@ -29,7 +29,13 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#if defined(HAVE_UCONTEXT_H) && (defined(__ia64__) || defined(HAVE_NATIVETHREAD))
|
||||||
|
#include <ucontext.h>
|
||||||
|
#define USE_CONTEXT
|
||||||
|
#else
|
||||||
#include <setjmp.h>
|
#include <setjmp.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "st.h"
|
#include "st.h"
|
||||||
#include "dln.h"
|
#include "dln.h"
|
||||||
|
|
||||||
@ -82,12 +88,35 @@ char *strrchr _((const char*,const char));
|
|||||||
#include "macruby_private.h"
|
#include "macruby_private.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef USE_CONTEXT
|
||||||
|
typedef struct {
|
||||||
|
ucontext_t context;
|
||||||
|
volatile int status;
|
||||||
|
} rb_jmpbuf_t[1];
|
||||||
|
|
||||||
|
#undef longjmp
|
||||||
|
#undef setjmp
|
||||||
|
NORETURN(static void rb_jump_context(rb_jmpbuf_t, int));
|
||||||
|
static inline void
|
||||||
|
rb_jump_context(env, val)
|
||||||
|
rb_jmpbuf_t env;
|
||||||
|
int val;
|
||||||
|
{
|
||||||
|
env->status = val;
|
||||||
|
setcontext(&env->context);
|
||||||
|
abort(); /* ensure noreturn */
|
||||||
|
}
|
||||||
|
#define longjmp(env, val) rb_jump_context(env, val)
|
||||||
|
#define setjmp(j) ((j)->status = 0, getcontext(&(j)->context), (j)->status)
|
||||||
|
#else
|
||||||
|
typedef jmp_buf rb_jmpbuf_t;
|
||||||
#ifndef setjmp
|
#ifndef setjmp
|
||||||
#ifdef HAVE__SETJMP
|
#ifdef HAVE__SETJMP
|
||||||
#define setjmp(env) _setjmp(env)
|
#define setjmp(env) _setjmp(env)
|
||||||
#define longjmp(env,val) _longjmp(env,val)
|
#define longjmp(env,val) _longjmp(env,val)
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
@ -847,7 +876,7 @@ static struct iter *ruby_iter;
|
|||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
struct tag {
|
struct tag {
|
||||||
jmp_buf buf;
|
rb_jmpbuf_t buf;
|
||||||
struct FRAME *frame;
|
struct FRAME *frame;
|
||||||
struct iter *iter;
|
struct iter *iter;
|
||||||
VALUE tag;
|
VALUE tag;
|
||||||
@ -7858,7 +7887,6 @@ Init_Proc()
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __ia64__
|
#ifdef __ia64__
|
||||||
#include <ucontext.h>
|
|
||||||
#if defined(__FreeBSD__)
|
#if defined(__FreeBSD__)
|
||||||
/*
|
/*
|
||||||
* FreeBSD/ia64 currently does not have a way for a process to get the
|
* FreeBSD/ia64 currently does not have a way for a process to get the
|
||||||
@ -7963,12 +7991,7 @@ enum thread_status {
|
|||||||
|
|
||||||
struct thread {
|
struct thread {
|
||||||
struct thread *next, *prev;
|
struct thread *next, *prev;
|
||||||
#ifdef __ia64__
|
rb_jmpbuf_t context;
|
||||||
ucontext_t context;
|
|
||||||
int context_status;
|
|
||||||
#else
|
|
||||||
jmp_buf context;
|
|
||||||
#endif
|
|
||||||
#ifdef SAVE_WIN32_EXCEPTION_LIST
|
#ifdef SAVE_WIN32_EXCEPTION_LIST
|
||||||
DWORD win32_exception_list;
|
DWORD win32_exception_list;
|
||||||
#endif
|
#endif
|
||||||
@ -8350,12 +8373,13 @@ rb_thread_save_context(th)
|
|||||||
th->stk_len = len;
|
th->stk_len = len;
|
||||||
FLUSH_REGISTER_WINDOWS;
|
FLUSH_REGISTER_WINDOWS;
|
||||||
MEMCPY(th->stk_ptr, th->stk_pos, VALUE, th->stk_len);
|
MEMCPY(th->stk_ptr, th->stk_pos, VALUE, th->stk_len);
|
||||||
#ifdef __ia64__
|
#ifdef USE_CONTEXT
|
||||||
{
|
{
|
||||||
ucontext_t ctx;
|
ucontext_t ctx;
|
||||||
VALUE *top, *bot;
|
VALUE *top, *bot;
|
||||||
|
|
||||||
getcontext(&ctx);
|
getcontext(&ctx);
|
||||||
|
#ifdef __ia64__
|
||||||
bot = (VALUE*)__libc_ia64_register_backing_store_base;
|
bot = (VALUE*)__libc_ia64_register_backing_store_base;
|
||||||
#if defined(__FreeBSD__)
|
#if defined(__FreeBSD__)
|
||||||
top = (VALUE*)ctx.uc_mcontext.mc_special.bspstore;
|
top = (VALUE*)ctx.uc_mcontext.mc_special.bspstore;
|
||||||
@ -8365,6 +8389,7 @@ rb_thread_save_context(th)
|
|||||||
th->bstr_len = top - bot;
|
th->bstr_len = top - bot;
|
||||||
REALLOC_N(th->bstr_ptr, VALUE, th->bstr_len);
|
REALLOC_N(th->bstr_ptr, VALUE, th->bstr_len);
|
||||||
MEMCPY(th->bstr_ptr, (VALUE*)__libc_ia64_register_backing_store_base, VALUE, th->bstr_len);
|
MEMCPY(th->bstr_ptr, (VALUE*)__libc_ia64_register_backing_store_base, VALUE, th->bstr_len);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef SAVE_WIN32_EXCEPTION_LIST
|
#ifdef SAVE_WIN32_EXCEPTION_LIST
|
||||||
@ -8434,16 +8459,9 @@ rb_thread_switch(n)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __ia64__
|
|
||||||
# define THREAD_SAVE_CONTEXT(th) \
|
|
||||||
(rb_thread_save_context(th),\
|
|
||||||
th->context_status = 0,\
|
|
||||||
rb_thread_switch((FLUSH_REGISTER_WINDOWS, getcontext(&th->context),(th)->context_status)))
|
|
||||||
#else
|
|
||||||
#define THREAD_SAVE_CONTEXT(th) \
|
#define THREAD_SAVE_CONTEXT(th) \
|
||||||
(rb_thread_save_context(th),\
|
(rb_thread_save_context(th),\
|
||||||
rb_thread_switch((FLUSH_REGISTER_WINDOWS, setjmp((th)->context))))
|
rb_thread_switch((FLUSH_REGISTER_WINDOWS, setjmp((th)->context))))
|
||||||
#endif
|
|
||||||
|
|
||||||
NORETURN(static void rb_thread_restore_context _((rb_thread_t,int)));
|
NORETURN(static void rb_thread_restore_context _((rb_thread_t,int)));
|
||||||
|
|
||||||
@ -8521,12 +8539,7 @@ rb_thread_restore_context(th, exit)
|
|||||||
rb_backref_set(tmp->last_match);
|
rb_backref_set(tmp->last_match);
|
||||||
tmp->last_match = tval;
|
tmp->last_match = tval;
|
||||||
|
|
||||||
#ifdef __ia64__
|
|
||||||
tmp->context_status = ex;
|
|
||||||
setcontext(&tmp->context);
|
|
||||||
#else
|
|
||||||
longjmp(tmp->context, ex);
|
longjmp(tmp->context, ex);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Loading…
x
Reference in New Issue
Block a user