Gentoo Archives: gentoo-commits

From: Sam James <sam@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/portage:master commit in: lib/portage/, lib/portage/util/
Date: Sat, 31 Dec 2022 13:33:12
Message-Id: 1672493584.9ef4e24ba6ff64bb1addb3112ebdf3b3e58bdb07.sam@gentoo
1 commit: 9ef4e24ba6ff64bb1addb3112ebdf3b3e58bdb07
2 Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
3 AuthorDate: Fri Dec 30 10:47:55 2022 +0000
4 Commit: Sam James <sam <AT> gentoo <DOT> org>
5 CommitDate: Sat Dec 31 13:33:04 2022 +0000
6 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=9ef4e24b
7
8 checksum: Consider C implementation of Whirlpool accelerated
9
10 Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>
11 Signed-off-by: Sam James <sam <AT> gentoo.org>
12
13 lib/portage/checksum.py | 9 ++++++---
14 lib/portage/util/whirlpool.py | 13 -------------
15 2 files changed, 6 insertions(+), 16 deletions(-)
16
17 diff --git a/lib/portage/checksum.py b/lib/portage/checksum.py
18 index f23897d91..3bdb2bc53 100644
19 --- a/lib/portage/checksum.py
20 +++ b/lib/portage/checksum.py
21 @@ -310,10 +310,13 @@ if "STREEBOG256" not in hashfunc_map or "STREEBOG512" not in hashfunc_map:
22 _whirlpool_unaccelerated = False
23 if "WHIRLPOOL" not in hashfunc_map:
24 # Bundled WHIRLPOOL implementation
25 - _whirlpool_unaccelerated = True
26 - from portage.util.whirlpool import new as _new_whirlpool
27 + from portage.util.whirlpool import CWhirlpool, PyWhirlpool
28
29 - _generate_hash_function("WHIRLPOOL", _new_whirlpool, origin="bundled")
30 + if CWhirlpool.is_available:
31 + _generate_hash_function("WHIRLPOOL", CWhirlpool, origin="bundled-c")
32 + else:
33 + _whirlpool_unaccelerated = True
34 + _generate_hash_function("WHIRLPOOL", PyWhirlpool, origin="bundled-py")
35
36
37 # There is only one implementation for size
38
39 diff --git a/lib/portage/util/whirlpool.py b/lib/portage/util/whirlpool.py
40 index 7caa20f6e..8454a874a 100644
41 --- a/lib/portage/util/whirlpool.py
42 +++ b/lib/portage/util/whirlpool.py
43 @@ -110,19 +110,6 @@ class CWhirlpool:
44 return tempstr
45
46
47 -if WhirlpoolExt is not None:
48 - Whirlpool = CWhirlpool
49 -else:
50 - Whirlpool = PyWhirlpool
51 -
52 -
53 -def new(init=b""):
54 - """Return a new Whirlpool object. An optional string argument
55 - may be provided; if present, this string will be automatically
56 - hashed."""
57 - return Whirlpool(init)
58 -
59 -
60 #
61 # Private.
62 #