From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/12507 Path: news.gmane.org!.POSTED!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: Announce: libucontext 0.1.0 - work in progress libc-independent ucontext implementation Date: Tue, 13 Feb 2018 23:43:22 -0500 Message-ID: <20180214044322.GQ1627@brightrain.aerifal.cx> References: Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: blaine.gmane.org 1518583321 17410 195.159.176.226 (14 Feb 2018 04:42:01 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 14 Feb 2018 04:42:01 +0000 (UTC) User-Agent: Mutt/1.5.21 (2010-09-15) To: musl@lists.openwall.com Original-X-From: musl-return-12524-gllmg-musl=m.gmane.org@lists.openwall.com Wed Feb 14 05:41:57 2018 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.84_2) (envelope-from ) id 1elosu-0002od-4t for gllmg-musl@m.gmane.org; Wed, 14 Feb 2018 05:41:32 +0100 Original-Received: (qmail 16299 invoked by uid 550); 14 Feb 2018 04:43:35 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 16276 invoked from network); 14 Feb 2018 04:43:34 -0000 Content-Disposition: inline In-Reply-To: Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:12507 Archived-At: On Tue, Feb 13, 2018 at 09:42:36PM -0600, William Pitcock wrote: > Hello, > > I am pleased to announce the 0.1.0 release of libucontext, a library > which implements the ucontext.h functions (getcontext, setcontext, > makecontext and swapcontext), originally meant for use with gcompat, > but also useful for applications requiring the functions outside of > gcompat (such as when building against musl directly). > > Implementation completeness varies based on each architecture, with > the goal of having complete implementations across all presently > supported architectures in the next release, but, it should be noted > that for the most part the implementations provide workable behaviour > in real-world apps right now. In other words, it's what you would > expect for a 0.1.0 release. > > To use these functions, you just link to `-lucontext`, meaning you > could provide them in $LIBS when running configure scripts and have > everything most likely work out nicely. > > Download: http://distfiles.dereferenced.org/libucontext/libucontext-0.1.0.tar.xz > Building should hopefully be straightforward too. > > For Alpine and Adelie distributions, this package is available as > libucontext in the testing repository. Looks good. A couple observations: 1. Your implementations don't seem to save or restore signal masks. This of course makes them much faster and "better" for implementing coroutines etc., but if applications using them actually expect them to keep a context-local signal mask, they'll break. 2. Your asm makes effort to save and restore call-clobbered registers. setcontext does need to restore them if you want to be able to return to asynchronous contexts (like the ucontext argument to a signal handler) correctly, but there's no point in saving the call-clobbered registers in getcontext, since these registers are purely the getcontext function's "local variables", not a meaningful part of the context. Likewise the /* we need to restore %ecx because we clobbered it earlier */ comment in x86 getcontext.S does not make sense. Rich