summaryrefslogtreecommitdiff
path: root/cont.c
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-02-09 20:25:01 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-02-09 20:25:01 +0000
commit4bfa061e52c723e051d172c2d85cefb92aead1d9 (patch)
treec48ffa56f8ddc5406a89175413b288316358db69 /cont.c
parent47bb7f37a10a2d6c2d6075f3075a7f8cbe20bcfe (diff)
Partially revert r27949.
* cont.c (fiber_setcontext): Use longjmp() instead of swapcontext() on FreeBSD 9. [ruby-dev:41316] [Bug #3295] [Bug #5526] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@34530 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'cont.c')
-rw-r--r--cont.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/cont.c b/cont.c
index 490ffac80b..76146179b6 100644
--- a/cont.c
+++ b/cont.c
@@ -646,6 +646,17 @@ fiber_setcontext(rb_fiber_t *newfib, rb_fiber_t *oldfib)
/* swap machine context */
#ifdef _WIN32
SwitchToFiber(newfib->fib_handle);
+#elif defined(__FreeBSD__) /* FreeBSD 9 doesn't work with swapcontext */
+ if (!ruby_setjmp(oldfib->cont.jmpbuf)) {
+ if (newfib->status != RUNNING) {
+ if (setcontext(&newfib->context) < 0) {
+ rb_bug("context switch between fiber failed");
+ }
+ }
+ else {
+ ruby_longjmp(newfib->cont.jmpbuf, 1);
+ }
+ }
#else
swapcontext(&oldfib->context, &newfib->context);
#endif