From owner-freebsd-current@FreeBSD.ORG Sat Jun 12 15:35:33 2010 Return-Path: Delivered-To: current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6C1351065672 for ; Sat, 12 Jun 2010 15:35:33 +0000 (UTC) (envelope-from uqs@spoerlein.net) Received: from acme.spoerlein.net (acme.spoerlein.net [IPv6:2001:470:9a47::1]) by mx1.freebsd.org (Postfix) with ESMTP id D82698FC13 for ; Sat, 12 Jun 2010 15:35:32 +0000 (UTC) Received: from acme.spoerlein.net (localhost.spoerlein.net [IPv6:::1]) by acme.spoerlein.net (8.14.4/8.14.4) with ESMTP id o5CFZUtZ019612 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sat, 12 Jun 2010 17:35:30 +0200 (CEST) (envelope-from uqs@spoerlein.net) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=spoerlein.net; s=dkim200908; t=1276356931; bh=V9GF9y2m8EDTbPOcuiwQYP5qvePveK4x2Dnz+AYhUro=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Transfer-Encoding:In-Reply-To; b=iaxRHD8BKS4Dxd/82KXSWleT+/DjjEnr98OpLPlf0nZ0GtdWs5RA8rQbDYj8/KtL8 PSgSJnbKihwy32EiZkqhTuPmt+8fLAyQ5+JKfqlNQF/LVorzYvYchTJTP1ze7LQfbX vzZ5aRa2KTnBeao+8On0YCRPCpNuonIeLpBwDV3E= Received: (from uqs@localhost) by acme.spoerlein.net (8.14.4/8.14.4/Submit) id o5CFZTec019611; Sat, 12 Jun 2010 17:35:29 +0200 (CEST) (envelope-from uqs@spoerlein.net) Date: Sat, 12 Jun 2010 17:35:28 +0200 From: Ulrich =?utf-8?B?U3DDtnJsZWlu?= To: Dag-Erling =?utf-8?B?U23DuHJncmF2?= Message-ID: <20100612153526.GA3632@acme.spoerlein.net> Mail-Followup-To: Dag-Erling =?utf-8?B?U23DuHJncmF2?= , current@freebsd.org References: <20100611162118.GR39829@acme.spoerlein.net> <867hm5tl6u.fsf@ds4.des.no> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <867hm5tl6u.fsf@ds4.des.no> User-Agent: Mutt/1.5.20 (2009-06-14) Cc: current@freebsd.org Subject: Re: Cleanup for cryptographic algorithms vs. compiler optimizations X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 12 Jun 2010 15:35:33 -0000 On Fri, 11.06.2010 at 21:37:29 +0200, Dag-Erling Smørgrav wrote: > Ulrich Spörlein writes: > > optimizing compilers have a tendency to remove assignments that have > > no side effects. The code in sys/crypto/sha2/sha2.c is doing a lot of > > zeroing variables, which is however optimized away. [...] Is there a > > canonical way to zero those variables and should we use them (memset > > perhaps? what are the performance implications?) > > If you stick these variables in a struct, you can memset the struct to > zero them; if there are many of them, it may be faster than zeroing them > individually. > > Alternatively, you can use something like this: > > #define FORCE_ASSIGN(type, var, value) \ > *(volatile type *)&(var) = (value) Interesting trick, thanks. I'll try this ... Uli