Date: Sat, 12 Jun 2010 17:35:28 +0200 From: Ulrich =?utf-8?B?U3DDtnJsZWlu?= <uqs@spoerlein.net> To: Dag-Erling =?utf-8?B?U23DuHJncmF2?= <des@des.no> Cc: current@freebsd.org Subject: Re: Cleanup for cryptographic algorithms vs. compiler optimizations Message-ID: <20100612153526.GA3632@acme.spoerlein.net> In-Reply-To: <867hm5tl6u.fsf@ds4.des.no> References: <20100611162118.GR39829@acme.spoerlein.net> <867hm5tl6u.fsf@ds4.des.no>
next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, 11.06.2010 at 21:37:29 +0200, Dag-Erling Smørgrav wrote: > Ulrich Spörlein <uqs@spoerlein.net> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20100612153526.GA3632>