[PATCH 1/2] Optimize buffer xoring.

Jussi Kivilinna jussi.kivilinna at mbnet.fi
Thu Nov 29 19:25:41 CET 2012


Quoting Werner Koch <wk at gnupg.org>:

> On Thu, 29 Nov 2012 16:37, jussi.kivilinna at mbnet.fi said:
>
>> +#ifndef G10_BUFHELP_H
>> +#define G10_BUFHELP_H
>> +
>> +#include <stdint.h>
>
> You may only use stdint.h if it is available; see for example sha1.c.
> We are targeting C90 and not C99.

Ok.

>
>> +#if defined(__i386__) || defined(__x86_64__)
>> +/* These architechtures are able of unaligned memory accesses and can
>> +   handle those fast.
>> + */
>
> Really?  All of them?
>

Well, based on my own experiences and that in Linux kernel x86 is one  
of two architechtures that have config flag  
"HAVE_EFFICIENT_UNALIGNED_ACCESS" always enabled (and the other one  
being PowerPC).

>> +  ldst = (long *)dst;
>> +  lsrc1 = (const long *)src1;
>> +  lsrc2 = (const long *)src2;
>
> You assume sizeof(long)<=sizeof(void*) - that should be okay.  However
> this is only optimal on Unix systems where sizeof(long)== sizeof(void*);
> Windows 64 bit has sizeof(long long)==sizeof(void*).  Thus tehre should
> be some space for further improvement.

I'll make v2 of this path, with stdint.h/intptr_t corrected and here  
use 'uintptr_t' instead of 'long'.

-Jussi

>
>
> Shalom-Salam,
>
>    Werner
>
> --
> Die Gedanken sind frei.  Ausnahmen regelt ein Bundesgesetz.
>
>
>






More information about the Gcrypt-devel mailing list