From owner-freebsd-current@FreeBSD.ORG Fri Jun 11 19:39:41 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 0AC661065673 for ; Fri, 11 Jun 2010 19:39:41 +0000 (UTC) (envelope-from des@des.no) Received: from smtp.des.no (smtp.des.no [194.63.250.102]) by mx1.freebsd.org (Postfix) with ESMTP id C013E8FC14 for ; Fri, 11 Jun 2010 19:39:40 +0000 (UTC) Received: from ds4.des.no (des.no [84.49.246.2]) by smtp.des.no (Postfix) with ESMTP id D031A1FFC33 for ; Fri, 11 Jun 2010 19:39:39 +0000 (UTC) Received: by ds4.des.no (Postfix, from userid 1001) id C503184488; Fri, 11 Jun 2010 21:37:29 +0200 (CEST) From: =?utf-8?Q?Dag-Erling_Sm=C3=B8rgrav?= To: current@freebsd.org References: <20100611162118.GR39829@acme.spoerlein.net> Date: Fri, 11 Jun 2010 21:37:29 +0200 In-Reply-To: <20100611162118.GR39829@acme.spoerlein.net> ("Ulrich =?utf-8?Q?Sp=C3=B6rlein=22's?= message of "Fri, 11 Jun 2010 18:21:18 +0200") Message-ID: <867hm5tl6u.fsf@ds4.des.no> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.95 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Cc: 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: Fri, 11 Jun 2010 19:39:41 -0000 Ulrich Sp=C3=B6rlein 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) =3D (value) DES --=20 Dag-Erling Sm=C3=B8rgrav - des@des.no