Removed code duplicate.

This commit is contained in:
XMRig 2020-05-09 01:13:46 +07:00
parent 85af4e27ec
commit 3cbf0dc0ee
No known key found for this signature in database
GPG key ID: 446A53638BE94409
16 changed files with 107 additions and 241 deletions

View file

@ -5,8 +5,8 @@
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -39,10 +39,39 @@ static String implName;
} // namespace xmrig
bool xmrig::argon2::Impl::select(const String &nameHint)
extern "C" {
extern int xmrig_ar2_check_avx512f();
extern int xmrig_ar2_check_avx2();
extern int xmrig_ar2_check_ssse3();
extern int xmrig_ar2_check_sse2();
}
bool xmrig::argon2::Impl::select(const String &nameHint, bool benchmark)
{
if (!selected) {
if (nameHint.isEmpty() || argon2_select_impl_by_name(nameHint) == 0) {
auto hint = nameHint;
if (hint.isEmpty() && !benchmark) {
if (xmrig_ar2_check_avx512f()) {
hint = "AVX-512F";
}
else if (xmrig_ar2_check_avx2()) {
hint = "AVX2";
}
else if (xmrig_ar2_check_ssse3()) {
hint = "SSSE3";
}
else if (xmrig_ar2_check_sse2()) {
hint = "SSE2";
}
}
if (hint.isEmpty() || argon2_select_impl_by_name(hint) == 0) {
argon2_select_impl();
}

View file

@ -5,8 +5,8 @@
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -38,7 +38,7 @@ namespace argon2 {
class Impl
{
public:
static bool select(const String &nameHint);
static bool select(const String &nameHint, bool benchmark = false);
static const String &name();
};