From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9269 invoked by alias); 28 May 2009 18:23:33 -0000 Received: (qmail 9253 invoked by uid 22791); 28 May 2009 18:23:30 -0000 X-SWARE-Spam-Status: No, hits=-1.1 required=5.0 tests=AWL,BAYES_20,J_CHICKENPOX_43 X-Spam-Check-By: sourceware.org Received: from mail3.caviumnetworks.com (HELO mail3.caviumnetworks.com) (12.108.191.235) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 28 May 2009 18:23:24 +0000 Received: from exch4.caveonetworks.com (Not Verified[192.168.16.23]) by mail3.caviumnetworks.com with MailMarshal (v6,2,2,3503) id ; Thu, 28 May 2009 14:23:00 -0400 Received: from exch4.caveonetworks.com ([192.168.16.23]) by exch4.caveonetworks.com with Microsoft SMTPSVC(6.0.3790.3959); Thu, 28 May 2009 11:23:09 -0700 Received: from localhost ([64.169.86.201]) by exch4.caveonetworks.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.3959); Thu, 28 May 2009 11:23:09 -0700 From: Adam Nemet MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <18974.54928.429649.794741@ropi.home> Date: Thu, 28 May 2009 21:01:00 -0000 To: Jamie Prescott Cc: gcc@gcc.gnu.org Subject: Re: Forgetting return values In-Reply-To: <353851.97620.qm@web111617.mail.gq1.yahoo.com> References: <516867.32690.qm@web111606.mail.gq1.yahoo.com> <353851.97620.qm@web111617.mail.gq1.yahoo.com> Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org X-SW-Source: 2009-05/txt/msg00663.txt.bz2 Jamie Prescott writes: > > From: Adam Nemet > > Jamie Prescott writes: > > > static inline int set_prop(char const *path, char const *name, > > > void const *data, int size) > > > { > > > int error; > > > > > > asm volatile ("int\t11\n\t" > > > : "=a0" (error): "a0" (path), "a1" (name), "a2" (data), > > > "a3" (size)); > > > > > > return error; > > > } > > > > > > extern int calc(int); > > > > > > int proc(int i) > > > { > > > int j = calc(i); > > > > > > return set_prop(0, 0, &j, sizeof(int)); > > > } > > ... > > > > > > Why is the memory clobber required, and why GCC does not understand to > > > sync the value to memory when passing the address to a function? > > > > Because you never inform GCC that you will use the value at > > address *NAME. Try to use "m"(*name) rather than "a1"(name) in the asm. > > That's 'data', not 'name'. But OK, got it. unfortunately, I cannot use "m" since > that value need to go into a specific register. > Any other solution? You can also have it *in addition* as an argument to the asm that's never used: asm volatile ("int\t11\n\t" : "=a0" (error): "a0" (path), "a1" (name), "a2" (data), "a3" (size), "m"(*data)); after changing data's type into something that can be dereferenced. Adam