Date: Fri, 11 Jun 2010 21:37:29 +0200 From: =?utf-8?Q?Dag-Erling_Sm=C3=B8rgrav?= <des@des.no> To: current@freebsd.org Subject: Re: Cleanup for cryptographic algorithms vs. compiler optimizations Message-ID: <867hm5tl6u.fsf@ds4.des.no> 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 %2B0200") References: <20100611162118.GR39829@acme.spoerlein.net>
next in thread | previous in thread | raw e-mail | index | archive | help
Ulrich Sp=C3=B6rlein <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) =3D (value) DES --=20 Dag-Erling Sm=C3=B8rgrav - des@des.no
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?867hm5tl6u.fsf>