mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-08-02 20:24:39 +02:00
address peer review: typography in linuxkm/linuxkm_memory.c, typography, clarity, and efficiency in wolfcrypt/src/sha256.c and wolfcrypt/src/sha512.c.
This commit is contained in:
@@ -237,9 +237,7 @@ static struct wc_thread_fpu_count_ent *wc_linuxkm_fpu_state_assoc(int create_p)
|
||||
* this is not thread-safe and doesn't need to be.
|
||||
*/
|
||||
int ret = allocate_wolfcrypt_linuxkm_fpu_states();
|
||||
if (ret == 0) {
|
||||
}
|
||||
else
|
||||
if (ret != 0)
|
||||
#endif
|
||||
{
|
||||
if (_warned_on_null == 0) {
|
||||
@@ -307,9 +305,7 @@ static struct wc_thread_fpu_count_ent *wc_linuxkm_fpu_state_assoc_unlikely(int c
|
||||
* this is not thread-safe and doesn't need to be.
|
||||
*/
|
||||
int ret = allocate_wolfcrypt_linuxkm_fpu_states();
|
||||
if (ret == 0) {
|
||||
}
|
||||
else
|
||||
if (ret != 0)
|
||||
#endif
|
||||
{
|
||||
if (_warned_on_null == 0) {
|
||||
@@ -458,7 +454,6 @@ WARN_UNUSED_RESULT int can_save_vector_registers_x86(void)
|
||||
return 0;
|
||||
else if (test_thread_flag(TIF_NEED_FPU_LOAD))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@@ -232,14 +232,14 @@ on the specific device platform.
|
||||
(!defined(WOLFSSL_HAVE_PSA) || defined(WOLFSSL_PSA_NO_HASH)) && \
|
||||
!defined(WOLFSSL_RENESAS_RX64_HASH)
|
||||
|
||||
#if defined(WOLFSSL_X86_64_BUILD) && defined(USE_INTEL_SPEEDUP) && (defined(HAVE_INTEL_AVX1) || defined(HAVE_INTEL_AVX2))
|
||||
static void Sha256_SetTransform(
|
||||
#if defined(WOLFSSL_X86_64_BUILD) && defined(USE_INTEL_SPEEDUP) && \
|
||||
(defined(HAVE_INTEL_AVX1) || defined(HAVE_INTEL_AVX2))
|
||||
#ifdef WC_C_DYNAMIC_FALLBACK
|
||||
int *sha_method
|
||||
#define SHA256_SETTRANSFORM_ARGS int *sha_method
|
||||
#else
|
||||
void
|
||||
#define SHA256_SETTRANSFORM_ARGS void
|
||||
#endif
|
||||
);
|
||||
static void Sha256_SetTransform(SHA256_SETTRANSFORM_ARGS);
|
||||
#endif
|
||||
|
||||
static int InitSha256(wc_Sha256* sha256)
|
||||
@@ -266,7 +266,8 @@ static int InitSha256(wc_Sha256* sha256)
|
||||
sha256->used = 0;
|
||||
#endif
|
||||
|
||||
#if defined(WOLFSSL_X86_64_BUILD) && defined(USE_INTEL_SPEEDUP) && (defined(HAVE_INTEL_AVX1) || defined(HAVE_INTEL_AVX2))
|
||||
#if defined(WOLFSSL_X86_64_BUILD) && defined(USE_INTEL_SPEEDUP) && \
|
||||
(defined(HAVE_INTEL_AVX1) || defined(HAVE_INTEL_AVX2))
|
||||
/* choose best Transform function under this runtime environment */
|
||||
#ifdef WC_C_DYNAMIC_FALLBACK
|
||||
sha256->sha_method = 0;
|
||||
@@ -394,6 +395,8 @@ static int InitSha256(wc_Sha256* sha256)
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
static word32 intel_flags = 0;
|
||||
|
||||
#if defined(WC_C_DYNAMIC_FALLBACK) && !defined(WC_NO_INTERNAL_FUNCTION_POINTERS)
|
||||
#define WC_NO_INTERNAL_FUNCTION_POINTERS
|
||||
#endif
|
||||
@@ -405,21 +408,13 @@ static int InitSha256(wc_Sha256* sha256)
|
||||
SHA256_C };
|
||||
|
||||
#ifndef WC_C_DYNAMIC_FALLBACK
|
||||
static word32 intel_flags;
|
||||
static enum sha_methods sha_method = SHA256_UNSET;
|
||||
#endif
|
||||
|
||||
static void Sha256_SetTransform(
|
||||
#ifdef WC_C_DYNAMIC_FALLBACK
|
||||
int *sha_method
|
||||
#else
|
||||
void
|
||||
#endif
|
||||
)
|
||||
static void Sha256_SetTransform(SHA256_SETTRANSFORM_ARGS)
|
||||
{
|
||||
#ifdef WC_C_DYNAMIC_FALLBACK
|
||||
#define SHA_METHOD (*sha_method)
|
||||
word32 intel_flags;
|
||||
#else
|
||||
#define SHA_METHOD sha_method
|
||||
#endif
|
||||
@@ -433,6 +428,7 @@ static int InitSha256(wc_Sha256* sha256)
|
||||
}
|
||||
#endif
|
||||
|
||||
if (intel_flags == 0)
|
||||
intel_flags = cpuid_get_flags();
|
||||
|
||||
if (IS_INTEL_SHA(intel_flags)) {
|
||||
@@ -596,8 +592,6 @@ static int InitSha256(wc_Sha256* sha256)
|
||||
}
|
||||
#define XTRANSFORM_LEN(...) inline_XTRANSFORM_LEN(__VA_ARGS__)
|
||||
|
||||
static word32 intel_flags;
|
||||
|
||||
static void Sha256_SetTransform(void)
|
||||
{
|
||||
|
||||
|
@@ -207,13 +207,12 @@
|
||||
|
||||
#if defined(WOLFSSL_X86_64_BUILD) && defined(USE_INTEL_SPEEDUP) && \
|
||||
(defined(HAVE_INTEL_AVX1) || defined(HAVE_INTEL_AVX2))
|
||||
static void Sha512_SetTransform(
|
||||
#ifdef WC_C_DYNAMIC_FALLBACK
|
||||
int *sha_method
|
||||
#define SHA512_SETTRANSFORM_ARGS int *sha_method
|
||||
#else
|
||||
void
|
||||
#define SHA512_SETTRANSFORM_ARGS void
|
||||
#endif
|
||||
);
|
||||
static void Sha512_SetTransform(SHA512_SETTRANSFORM_ARGS);
|
||||
#endif
|
||||
|
||||
static int InitSha512(wc_Sha512* sha512)
|
||||
@@ -465,6 +464,8 @@ static int InitSha512_256(wc_Sha512* sha512)
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
static word32 intel_flags = 0;
|
||||
|
||||
#if defined(WC_C_DYNAMIC_FALLBACK) && !defined(WC_NO_INTERNAL_FUNCTION_POINTERS)
|
||||
#define WC_NO_INTERNAL_FUNCTION_POINTERS
|
||||
#endif
|
||||
@@ -478,20 +479,12 @@ static int InitSha512_256(wc_Sha512* sha512)
|
||||
|
||||
#ifndef WC_C_DYNAMIC_FALLBACK
|
||||
static enum sha_methods sha_method = SHA512_UNSET;
|
||||
static word32 intel_flags;
|
||||
#endif
|
||||
|
||||
static void Sha512_SetTransform(
|
||||
#ifdef WC_C_DYNAMIC_FALLBACK
|
||||
int *sha_method
|
||||
#else
|
||||
void
|
||||
#endif
|
||||
)
|
||||
static void Sha512_SetTransform(SHA512_SETTRANSFORM_ARGS)
|
||||
{
|
||||
#ifdef WC_C_DYNAMIC_FALLBACK
|
||||
#define SHA_METHOD (*sha_method)
|
||||
word32 intel_flags;
|
||||
#else
|
||||
#define SHA_METHOD sha_method
|
||||
#endif
|
||||
@@ -505,6 +498,7 @@ static int InitSha512_256(wc_Sha512* sha512)
|
||||
}
|
||||
#endif
|
||||
|
||||
if (intel_flags == 0)
|
||||
intel_flags = cpuid_get_flags();
|
||||
|
||||
#if defined(HAVE_INTEL_AVX2)
|
||||
@@ -641,8 +635,6 @@ static int InitSha512_256(wc_Sha512* sha512)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static word32 intel_flags;
|
||||
|
||||
static void Sha512_SetTransform(void)
|
||||
{
|
||||
if (transform_check)
|
||||
|
Reference in New Issue
Block a user