* eval.c (POST_GETCONTEXT): define separately from PRE_GETCONTEXT on

IA64 to avoid reusing variable address.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9852 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2006-01-22 13:17:39 +00:00
parent 8902cab770
commit 205e7c74ea
2 changed files with 58 additions and 44 deletions

View File

@ -1,7 +1,14 @@
Sun Jan 22 22:09:52 2006 Tanaka Akira <akr@m17n.org>
* eval.c (POST_GETCONTEXT): define separately from PRE_GETCONTEXT on
IA64 to avoid reusing variable address.
Sun Jan 22 20:03:35 2006 Tanaka Akira <akr@m17n.org> Sun Jan 22 20:03:35 2006 Tanaka Akira <akr@m17n.org>
* eval.c (ruby_setjmp): workaround for FreeBSD/i386 * eval.c (ruby_setjmp): define PRE_GETCONTEXT and POST_GETCONTEXT
getcontext/setcontext bug. instead of FUNCTION_CALL_MAY_RETURN_TWICE.
define PRE_GETCONTEXT to clear carry flag for workaround of
FreeBSD/i386 getcontext/setcontext bug.
[ruby-dev:28263] [ruby-dev:28263]
Thu Jan 19 22:19:18 2006 Minero Aoki <aamine@loveruby.net> Thu Jan 19 22:19:18 2006 Minero Aoki <aamine@loveruby.net>

71
eval.c
View File

@ -133,39 +133,43 @@ rb_jump_context(env, val)
* http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21957 * http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21957
* http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22127 * http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22127
*/ */
#define GCC_VERSION_BEFORE(major, minor, patchlevel) \ # define GCC_VERSION_BEFORE(major, minor, patchlevel) \
(defined(__GNUC__) && !defined(__INTEL_COMPILER) && \ (defined(__GNUC__) && !defined(__INTEL_COMPILER) && \
((__GNUC__ < (major)) || \ ((__GNUC__ < (major)) || \
(__GNUC__ == (major) && __GNUC_MINOR__ < (minor)) || \ (__GNUC__ == (major) && __GNUC_MINOR__ < (minor)) || \
(__GNUC__ == (major) && __GNUC_MINOR__ == (minor) && __GNUC_PATCHLEVEL__ < (patchlevel)))) (__GNUC__ == (major) && __GNUC_MINOR__ == (minor) && __GNUC_PATCHLEVEL__ < (patchlevel))))
#if GCC_VERSION_BEFORE(4,0,3) && (defined(sparc) || defined(__sparc__)) # if GCC_VERSION_BEFORE(4,0,3) && (defined(sparc) || defined(__sparc__))
#ifdef __pic__ # ifdef __pic__
/* /*
* %l7 is excluded for PIC because it is PIC register. * %l7 is excluded for PIC because it is PIC register.
* http://lists.freebsd.org/pipermail/freebsd-sparc64/2006-January/003739.html * http://lists.freebsd.org/pipermail/freebsd-sparc64/2006-January/003739.html
*/ */
#define PRE_GETCONTEXT \ # define PRE_GETCONTEXT \
({ __asm__ volatile ("" : : : \ ({ __asm__ volatile ("" : : : \
"%o0", "%o1", "%o2", "%o3", "%o4", "%o5", "%o7", \ "%o0", "%o1", "%o2", "%o3", "%o4", "%o5", "%o7", \
"%l0", "%l1", "%l2", "%l3", "%l4", "%l5", "%l6", \ "%l0", "%l1", "%l2", "%l3", "%l4", "%l5", "%l6", \
"%i0", "%i1", "%i2", "%i3", "%i4", "%i5", "%i7"); }) "%i0", "%i1", "%i2", "%i3", "%i4", "%i5", "%i7"); }),
#else # else
#define PRE_GETCONTEXT \ # define PRE_GETCONTEXT \
({ __asm__ volatile ("" : : : \ ({ __asm__ volatile ("" : : : \
"%o0", "%o1", "%o2", "%o3", "%o4", "%o5", "%o7", \ "%o0", "%o1", "%o2", "%o3", "%o4", "%o5", "%o7", \
"%l0", "%l1", "%l2", "%l3", "%l4", "%l5", "%l6", "%l7", \ "%l0", "%l1", "%l2", "%l3", "%l4", "%l5", "%l6", "%l7", \
"%i0", "%i1", "%i2", "%i3", "%i4", "%i5", "%i7"); }) "%i0", "%i1", "%i2", "%i3", "%i4", "%i5", "%i7"); }),
#endif # endif
#define POST_GETCONTEXT PRE_GETCONTEXT # define POST_GETCONTEXT PRE_GETCONTEXT
#elif GCC_VERSION_BEFORE(4,0,3) && defined(__ia64) # elif GCC_VERSION_BEFORE(4,0,3) && defined(__ia64)
static jmp_buf function_call_may_return_twice_jmp_buf; static jmp_buf function_call_may_return_twice_jmp_buf;
int function_call_may_return_twice_false = 0; int function_call_may_return_twice_false_1 = 0;
#define PRE_GETCONTEXT \ int function_call_may_return_twice_false_2 = 0;
(function_call_may_return_twice_false ? \ # define PRE_GETCONTEXT \
(function_call_may_return_twice_false_1 ? \
setjmp(function_call_may_return_twice_jmp_buf) : \ setjmp(function_call_may_return_twice_jmp_buf) : \
0) 0),
#define POST_GETCONTEXT PRE_GETCONTEXT # define POST_GETCONTEXT \
#elif defined(__FreeBSD__) (function_call_may_return_twice_false_2 ? \
setjmp(function_call_may_return_twice_jmp_buf) : \
0),
# elif defined(__FreeBSD__)
/* /*
* workaround for FreeBSD/i386 getcontext/setcontext bug. * workaround for FreeBSD/i386 getcontext/setcontext bug.
* clear the carry flag by (0 ? ... : ...). * clear the carry flag by (0 ? ... : ...).
@ -173,30 +177,33 @@ int function_call_may_return_twice_false = 0;
* [ruby-dev:28263] * [ruby-dev:28263]
*/ */
static int volatile freebsd_clear_carry_flag = 0; static int volatile freebsd_clear_carry_flag = 0;
#define PRE_GETCONTEXT (freebsd_clear_carry_flag ? (freebsd_clear_carry_flag = 0) : 0) # define PRE_GETCONTEXT \
#endif (freebsd_clear_carry_flag ? (freebsd_clear_carry_flag = 0) : 0),
# endif
# ifndef PRE_GETCONTEXT # ifndef PRE_GETCONTEXT
# define PRE_GETCONTEXT 0 # define PRE_GETCONTEXT
# endif # endif
# ifndef POST_GETCONTEXT # ifndef POST_GETCONTEXT
# define POST_GETCONTEXT 0 # define POST_GETCONTEXT
# endif # endif
#define ruby_longjmp(env, val) rb_jump_context(env, val) # define ruby_longjmp(env, val) rb_jump_context(env, val)
#define ruby_setjmp(just_before_setjmp, j) ((j)->status = 0, \ # define ruby_setjmp(just_before_setjmp, j) ((j)->status = 0, \
(just_before_setjmp), \ (just_before_setjmp), \
PRE_GETCONTEXT, \ PRE_GETCONTEXT \
getcontext(&(j)->context), \ getcontext(&(j)->context), \
POST_GETCONTEXT, \ POST_GETCONTEXT \
(j)->status) (j)->status)
#else #else
typedef jmp_buf rb_jmpbuf_t; typedef jmp_buf rb_jmpbuf_t;
#if !defined(setjmp) && defined(HAVE__SETJMP) # if !defined(setjmp) && defined(HAVE__SETJMP)
#define ruby_setjmp(just_before_setjmp, env) ((just_before_setjmp), _setjmp(env)) # define ruby_setjmp(just_before_setjmp, env) \
#define ruby_longjmp(env,val) _longjmp(env,val) ((just_before_setjmp), _setjmp(env))
#else # define ruby_longjmp(env,val) _longjmp(env,val)
#define ruby_setjmp(just_before_setjmp, env) ((just_before_setjmp), setjmp(env)) # else
#define ruby_longjmp(env,val) longjmp(env,val) # define ruby_setjmp(just_before_setjmp, env) \
#endif ((just_before_setjmp), setjmp(env))
# define ruby_longjmp(env,val) longjmp(env,val)
# endif
#endif #endif
#include <sys/types.h> #include <sys/types.h>