From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.3 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL autolearn=ham autolearn_force=no version=3.4.2 Received: (qmail 17661 invoked from network); 24 Apr 2020 01:20:58 -0000 Received: from mother.openwall.net (195.42.179.200) by inbox.vuxu.org with UTF8ESMTPZ; 24 Apr 2020 01:20:58 -0000 Received: (qmail 12241 invoked by uid 550); 24 Apr 2020 01:20:57 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 12220 invoked from network); 24 Apr 2020 01:20:56 -0000 Date: Thu, 23 Apr 2020 21:20:43 -0400 From: Rich Felker To: Tom Storey Cc: musl@lists.openwall.com Message-ID: <20200424012043.GB11469@brightrain.aerifal.cx> References: <20200423023255.GO11469@brightrain.aerifal.cx> <20200423163016.GW11469@brightrain.aerifal.cx> <20200424005101.GA11469@brightrain.aerifal.cx> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Subject: Re: [musl] 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