mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: musl@lists.openwall.com
Subject: Re: Announce: libucontext 0.1.0 - work in progress libc-independent ucontext implementation
Date: Tue, 13 Feb 2018 23:43:22 -0500	[thread overview]
Message-ID: <20180214044322.GQ1627@brightrain.aerifal.cx> (raw)
In-Reply-To: <CA+T2pCF9STZGG-y=EV4y1SQhwdgp7NmJO0jNiztC6gds52nzyg@mail.gmail.com>

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


  reply	other threads:[~2018-02-14  4:43 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-14  3:42 William Pitcock
2018-02-14  4:43 ` Rich Felker [this message]
2018-02-14  5:08   ` William Pitcock

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180214044322.GQ1627@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).