From owner-freebsd-sparc Sat Dec 7 6:52:13 2002 Delivered-To: freebsd-sparc@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id DB09137B401; Sat, 7 Dec 2002 06:52:10 -0800 (PST) Received: from flood.ping.uio.no (flood.ping.uio.no [129.240.78.31]) by mx1.FreeBSD.org (Postfix) with ESMTP id D942C43EB2; Sat, 7 Dec 2002 06:52:09 -0800 (PST) (envelope-from des@ofug.org) Received: by flood.ping.uio.no (Postfix, from userid 2602) id 857D05374; Sat, 7 Dec 2002 15:52:02 +0100 (CET) X-URL: http://www.ofug.org/~des/ X-Disclaimer: The views expressed in this message do not necessarily coincide with those of any organisation or company with which I am or have been affiliated. To: sparc@freebsd.org Cc: peter@freebsd.org Subject: libc_r From: Dag-Erling Smorgrav Date: Sat, 07 Dec 2002 15:52:01 +0100 Message-ID: Lines: 27 User-Agent: Gnus/5.090007 (Oort Gnus v0.07) Emacs/21.2 (i386--freebsd) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Sender: owner-freebsd-sparc@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org --=-=-= I was quite surprised to discover that sparc64, which is supposedly a tier 1 platform and our reference 64-bit platform, doesn't have a working libc_r, so I decided to take a shot at it. I've arrived at what I believe is a correct implementation for _atomic_lock() (see attached source code). It seems to work as expected when called from a simple test program which attempts to acquire the same lock twice: l is now 0x0 _atomic_lock() returned 0x0 l after _atomic_lock(): 0xff00000000000000 l is now 0xff00000000000000 _atomic_lock() returned 0xff l after _atomic_lock(): 0xff00000000000000 I've never written sparc assembler before, so caveat emptor, slippery when wet, do not look into laser with remaining eye, etc. I haven't started on pthread_private.h yet, and I'm not sure I can handle it on my own, but I hope this will inspire someone to tackle it. DES -- Dag-Erling Smorgrav - des@ofug.org --=-=-= Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: attachment; filename=_atomic_lock.S Content-Transfer-Encoding: quoted-printable /*- * Copyright (c) 2002 Dag-Erling Co=EFdan Sm=F8rgrav * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer * in this position and unchanged. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include __FBSDID("$FreeBSD$"); /* * long _atomic_lock(long *) * * Atomically acquire a lock by storing a non-zero value in its * location, provided it is not already locked. Note that we only use * the first byte of the location provided. */ ENTRY(_atomic_lock) ldstub [%o0], %o1 membar #LoadLoad retl mov %o1, %o0 END(_atomic_lock) --=-=-=-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-sparc" in the body of the message