|
|
Subscribe / Log in / New account

Re: getcontext/setcontext alternatives

Re: getcontext/setcontext alternatives

Posted May 9, 2012 11:20 UTC (Wed) by geertj (guest, #4116)
In reply to: Re: getcontext/setcontext alternatives by scottt
Parent article: nPth - The new GNU portable threads library

> What's the alternative to getcontext() and friends? Going back to manually
> writing per arch "stack switching" code like cgreenlet/greenlet-asm.S?

One trick that is sometimes used is sigaltstack() + setjmp(). However i would argue this is actually less portable than writing assembly (the assembly you refer to above is not OS specific, it is only architecture specific and the same function it works on Linux, Mac OSX and Windows).

In the best case, we would get a working and not-deprecated makecontext() function from libc at some point. Also we would need to get an extended longjmp() that allows for code injection in the target co-routine (for propagating exceptions in C++).


to post comments

Re: getcontext/setcontext alternatives

Posted May 11, 2012 23:53 UTC (Fri) by jwakely (subscriber, #60262) [Link]

Can std::current_exception and std::rethrow_exception be used for that exception propagation or are they insufficient?


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds