From owner-freebsd-current Fri Dec 8 10:46:54 2000 From owner-freebsd-current@FreeBSD.ORG Fri Dec 8 10:46:52 2000 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from pike.osd.bsdi.com (pike.osd.bsdi.com [204.216.28.222]) by hub.freebsd.org (Postfix) with ESMTP id 4D1EC37B400 for ; Fri, 8 Dec 2000 10:46:52 -0800 (PST) Received: from foo.osd.bsdi.com (root@foo.osd.bsdi.com [204.216.28.137]) by pike.osd.bsdi.com (8.11.1/8.9.3) with ESMTP id eB8IkG759676; Fri, 8 Dec 2000 10:46:16 -0800 (PST) (envelope-from jhb@foo.osd.bsdi.com) Received: (from jhb@localhost) by foo.osd.bsdi.com (8.11.1/8.11.0) id eB8IkJv75081; Fri, 8 Dec 2000 10:46:19 -0800 (PST) (envelope-from jhb) Message-ID: X-Mailer: XFMail 1.4.0 on FreeBSD X-Priority: 3 (Normal) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 8bit MIME-Version: 1.0 In-Reply-To: <3A31236B.23501A47@elischer.org> Date: Fri, 08 Dec 2000 10:46:18 -0800 (PST) Organization: BSD, Inc. From: John Baldwin To: Julian Elischer Subject: RE: __asm help.. Cc: current@FreeBSD.ORG Sender: jhb@foo.osd.bsdi.com Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On 08-Dec-00 Julian Elischer wrote: > I'm trying to write some experimental mutex operations similar to those > in -current, but to do differnt things (e.g. a read/write lock) > however, I am having some problems with the __asm stuff. > > What I want to do is to define some operations that will > assemble down to: > pushfl > cli > [stuff] > popfl > > I can generate the code, but it seems to me that there should be > a way of telling gcc that you have just pushed an item onto the stack, > so that if you were to have some C code between the push and po > (of the flags reg) the compiler has a correct idea of where the > SP is. I can imagine that it doesn't matter so it may be that there > is no constaint for that purpose (I read the gcc asm info pages) > but I wanted to make sure that that is the case because if it does turn > out to be important, it may manifest itself as a wierd bug sometime > in 2002. As long as gcc uses %ebp to address local variables and functoin parameters rather than %esp you should be fine. %esp will be preserved, but if %esp is for some odd reason used to address a variable during the C code, you are hosed. Just use foo = save_intr(); disable_intr(); .. restore_intr() for now. If you want to save the 2 instructions so badly, then you should probably be writing the whole chunk in assembly. Getting it correct first and optimizing later is more sane than getting correctness and optimization at the same time and not knowing which one your bugs are coming from. -- John Baldwin -- http://www.FreeBSD.org/~jhb/ PGP Key: http://www.Baldwin.cx/~john/pgpkey.asc "Power Users Use the Power to Serve!" - http://www.FreeBSD.org/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message