Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200424012043.GB11469@brightrain.aerifal.cx>
Date: Thu, 23 Apr 2020 21:20:43 -0400
From: Rich Felker <dalias@...c.org>
To: Tom Storey <tom@...ap.net>
Cc: musl@...ts.openwall.com
Subject: Re: Building for m68k

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

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.