Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Nettle
nettle
Commits
ad87c2b2
Commit
ad87c2b2
authored
Oct 23, 2014
by
Niels Möller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
For memxor, make word_t be always 64 bits on x86_64.
parent
5ce02c32
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
9 deletions
+12
-9
ChangeLog
ChangeLog
+2
-0
memxor.c
memxor.c
+10
-9
No files found.
ChangeLog
View file @
ad87c2b2
...
...
@@ -3,6 +3,8 @@
* memxor.c (memxor_common_alignment, memxor_different_alignment)
(memxor): Change loop order, iterate from the end.
(memxor3_common_alignment): Unroll twice.
(word_t): On x86_64, unconditionally define as uint64_t, to get 64
bits also in M$ windows. Replaced all uses of SIZEOF_LONG.
* examples/nettle-benchmark.c (time_memxor): Allocate buffers as
arrays of unsigned long, for more reliable alignment.
...
...
memxor.c
View file @
ad87c2b2
...
...
@@ -44,10 +44,11 @@
/* For uintptr_t */
#include "nettle-types.h"
#if defined(__x86_64__) || defined(__arch64__)
/* Including on M$ windows, where unsigned long is only 32 bits */
typedef
uint64_t
word_t
;
#else
typedef
unsigned
long
int
word_t
;
#if SIZEOF_LONG & (SIZEOF_LONG - 1)
#error Word size must be a power of two
#endif
#define ALIGN_OFFSET(p) ((uintptr_t) (p) % sizeof(word_t))
...
...
@@ -95,7 +96,7 @@ memxor_different_alignment (word_t *dst, const char *src, size_t n)
shl
=
CHAR_BIT
*
offset
;
shr
=
CHAR_BIT
*
(
sizeof
(
word_t
)
-
offset
);
src_word
=
(
const
word_t
*
)
((
uintptr_t
)
src
&
-
SIZEOF_LONG
);
src_word
=
(
const
word_t
*
)
((
uintptr_t
)
src
&
-
sizeof
(
word_t
)
);
if
(
n
&
1
)
{
...
...
@@ -191,7 +192,7 @@ memxor3_different_alignment_b (word_t *dst,
shl
=
CHAR_BIT
*
offset
;
shr
=
CHAR_BIT
*
(
sizeof
(
word_t
)
-
offset
);
b_word
=
(
const
word_t
*
)
((
uintptr_t
)
b
&
-
SIZEOF_LONG
);
b_word
=
(
const
word_t
*
)
((
uintptr_t
)
b
&
-
sizeof
(
word_t
)
);
if
(
n
&
1
)
{
...
...
@@ -227,8 +228,8 @@ memxor3_different_alignment_ab (word_t *dst,
shl
=
CHAR_BIT
*
offset
;
shr
=
CHAR_BIT
*
(
sizeof
(
word_t
)
-
offset
);
a_word
=
(
const
word_t
*
)
((
uintptr_t
)
a
&
-
SIZEOF_LONG
);
b_word
=
(
const
word_t
*
)
((
uintptr_t
)
b
&
-
SIZEOF_LONG
);
a_word
=
(
const
word_t
*
)
((
uintptr_t
)
a
&
-
sizeof
(
word_t
)
);
b_word
=
(
const
word_t
*
)
((
uintptr_t
)
b
&
-
sizeof
(
word_t
)
);
if
(
n
&
1
)
{
...
...
@@ -267,8 +268,8 @@ memxor3_different_alignment_all (word_t *dst,
bl
=
CHAR_BIT
*
b_offset
;
br
=
CHAR_BIT
*
(
sizeof
(
word_t
)
-
b_offset
);
a_word
=
(
const
word_t
*
)
((
uintptr_t
)
a
&
-
SIZEOF_LONG
);
b_word
=
(
const
word_t
*
)
((
uintptr_t
)
b
&
-
SIZEOF_LONG
);
a_word
=
(
const
word_t
*
)
((
uintptr_t
)
a
&
-
sizeof
(
word_t
)
);
b_word
=
(
const
word_t
*
)
((
uintptr_t
)
b
&
-
sizeof
(
word_t
)
);
if
(
n
&
1
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment