mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: Tom Storey <tom@snnap.net>
Cc: musl@lists.openwall.com
Subject: Re: [musl] Building for m68k
Date: Thu, 23 Apr 2020 21:20:43 -0400	[thread overview]
Message-ID: <20200424012043.GB11469@brightrain.aerifal.cx> (raw)
In-Reply-To: <CAFDgZgW9AUMzwh_fqo3vN97Xp2X12-1wuGU+htGH7nPk_25YWw@mail.gmail.com>

On Fri, Apr 24, 2020 at 11:14:38AM +1000, Tom Storey wrote:
> Sorry to ask what sounds like a dumb question, but is
> 
> cli;nonatomic_cas;sti
> 
> basically "disable interrupts, do something equivalent to cas, re-enable
> interrupts"?

Yeah. Basically:

static inline int a_cas(volatile int *p, int t, int s)
{
	__asm__ __volatile__("cli" : : : "memory");
	if (*p==t) *p=s; else t=*p;
	__asm__ __volatile__("sti" : : : "memory");
	return t;
}

where cli and sti are replaced with the m68k instructions for those
operations. Of course if you might have code that already has
interrupts disabled somewhere calling libc stuff, you may need to make
it save the old interrupt state and restore it rather than just sti.
See the sh2 version (runtime selected so it's in __sh_cas_imask in
src/thread/sh/atomics.s and atomic_arch.h just calls the
runtime-selected function) for an example of code doing this

Rich

  reply	other threads:[~2020-04-24  1:20 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-23  2:05 Tom Storey
2020-04-23  2:32 ` Rich Felker
2020-04-23  5:04   ` Tom Storey
2020-04-23 16:30     ` Rich Felker
2020-04-24  0:36       ` Tom Storey
2020-04-24  0:51         ` Rich Felker
2020-04-24  1:14           ` Tom Storey
2020-04-24  1:20             ` Rich Felker [this message]
2020-04-24  2:29               ` Tom Storey
2020-04-24  2:37                 ` Rich Felker

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=20200424012043.GB11469@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --cc=musl@lists.openwall.com \
    --cc=tom@snnap.net \
    /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).