From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/12508 Path: news.gmane.org!.POSTED!not-for-mail From: William Pitcock 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:08:30 -0600 Message-ID: References: <20180214044322.GQ1627@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" X-Trace: blaine.gmane.org 1518584820 7934 195.159.176.226 (14 Feb 2018 05:07:00 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 14 Feb 2018 05:07:00 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-12525-gllmg-musl=m.gmane.org@lists.openwall.com Wed Feb 14 06:06:56 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 1elpHF-0000qL-Gd for gllmg-musl@m.gmane.org; Wed, 14 Feb 2018 06:06:41 +0100 Original-Received: (qmail 9274 invoked by uid 550); 14 Feb 2018 05:08:44 -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 9249 invoked from network); 14 Feb 2018 05:08:43 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dereferenced-org.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=y0K7i0S8RyxF2VM6Zkibt+CM54qC/Mp2htM7KPrNFx0=; b=sZINC8LDO7y5syzUmO9Vt7BGGrdMoxUJMJfBI6tgTsETBO9kXdm2Q6Ck+JZ3ONa9kb 5j8i2FGxauEm2EFtn7brSlbE/kNl0PsWIgURzoppFGxyH9roZ+l4ghkW5g8AzRd4HV+t WLj0R+7hDNArzfS7ktWlZFJqsFXMPttWE/SoSmkKi6xeuJagzRkAuxcAgzn7xlZ0lODu BqUy88H3gOpzUke/vzuoOldISay9hmPtSEgR5LTEptashTlql5ythTIdoAZjgDXm6DTx zYx0RJ6nSwUccecW2wSGiK+mtUFSSnmQ8k5K9HiLXpOJ786u6KSTSyFdhjhn7lnzBMGy wihg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=y0K7i0S8RyxF2VM6Zkibt+CM54qC/Mp2htM7KPrNFx0=; b=eAZtfiiW2VlkOL8ui6o73vuy4WHPyfQ62cs1fFy5CQfEEbG92iG5dcu4Aq2OBBD5+K 5ErYKiJcCx60+T+9wECN8lWHFB9LDrPOLjeToLKICjihjT211LujbCJpeO4s1ne38Jn0 Pi6Lb1K5m81zpf1SNzyb+tQh0aD1MA9452D3TLqsbPUyLaRQDIERrZaXLNFEDyLhw/90 sitB+DHqMXTEnZycUtJP9reqD0qDOoN+jnZoB7IZ7e/cBV9JrL+TfKAbzZBsvW3a5yx5 4O8oCbPYo7meDNXmj82o4lqDGk5BFbVRgsrtKVSA+OGOWQDkVQ7TeFvsDBoByPl274c5 qocw== X-Gm-Message-State: APf1xPAvIP2nYcYZIaAHQRz3wqfrzYg86iRfpRtTyTJLbXTOuLZcpG5B FyMvEpysrsOaAfyC0jurjDx0leo8ToqYf3BjF9d8jQ== X-Google-Smtp-Source: AH8x227X1ZNqKKZkzCicKkhP+8LiRGl4v0L8jTD9PXMitw24dcbJXsKYB4aykf4LFlSyhDFJuJWUROLwTdeEAMYJHKI= X-Received: by 10.55.187.135 with SMTP id l129mr5777585qkf.322.1518584911485; Tue, 13 Feb 2018 21:08:31 -0800 (PST) In-Reply-To: <20180214044322.GQ1627@brightrain.aerifal.cx> Xref: news.gmane.org gmane.linux.lib.musl.general:12508 Archived-At: Hello, On Tue, Feb 13, 2018 at 10:43 PM, Rich Felker wrote: > 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. Signal masks are a planned feature in 0.2.0. 0.1.0 is mainly meant to be a proof of concept. > 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. You're right, we don't need to bother with fixing %ecx after saving the FS segment. William