forked from wolfSSL/wolfssl
wolfssl/wolfcrypt/sp_int.h: refactor SP_WORD_SIZEOF as a simple numeric literal, and use them for XALIGNED() for Windows portability.
This commit is contained in:
@@ -260,9 +260,6 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Number of bytes in each word. */
|
|
||||||
#define SP_WORD_SIZEOF (SP_WORD_SIZE / 8)
|
|
||||||
|
|
||||||
/* Define the types used. */
|
/* Define the types used. */
|
||||||
#if defined(HAVE___UINT128_T) && !defined(NO_INT128)
|
#if defined(HAVE___UINT128_T) && !defined(NO_INT128)
|
||||||
#ifdef __SIZEOF_INT128__
|
#ifdef __SIZEOF_INT128__
|
||||||
@@ -285,6 +282,8 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if SP_WORD_SIZE == 8
|
#if SP_WORD_SIZE == 8
|
||||||
|
#define SP_WORD_SIZEOF 1
|
||||||
|
|
||||||
typedef sp_uint8 sp_int_digit;
|
typedef sp_uint8 sp_int_digit;
|
||||||
typedef sp_int8 sp_int_sdigit;
|
typedef sp_int8 sp_int_sdigit;
|
||||||
typedef sp_uint16 sp_int_word;
|
typedef sp_uint16 sp_int_word;
|
||||||
@@ -292,6 +291,8 @@ extern "C" {
|
|||||||
|
|
||||||
#define SP_MASK 0xffU
|
#define SP_MASK 0xffU
|
||||||
#elif SP_WORD_SIZE == 16
|
#elif SP_WORD_SIZE == 16
|
||||||
|
#define SP_WORD_SIZEOF 2
|
||||||
|
|
||||||
typedef sp_uint16 sp_int_digit;
|
typedef sp_uint16 sp_int_digit;
|
||||||
typedef sp_int16 sp_int_sdigit;
|
typedef sp_int16 sp_int_sdigit;
|
||||||
typedef sp_uint32 sp_int_word;
|
typedef sp_uint32 sp_int_word;
|
||||||
@@ -299,6 +300,8 @@ extern "C" {
|
|||||||
|
|
||||||
#define SP_MASK 0xffffU
|
#define SP_MASK 0xffffU
|
||||||
#elif SP_WORD_SIZE == 32
|
#elif SP_WORD_SIZE == 32
|
||||||
|
#define SP_WORD_SIZEOF 4
|
||||||
|
|
||||||
typedef sp_uint32 sp_int_digit;
|
typedef sp_uint32 sp_int_digit;
|
||||||
typedef sp_int32 sp_int_sdigit;
|
typedef sp_int32 sp_int_sdigit;
|
||||||
typedef sp_uint64 sp_int_word;
|
typedef sp_uint64 sp_int_word;
|
||||||
@@ -306,6 +309,8 @@ extern "C" {
|
|||||||
|
|
||||||
#define SP_MASK 0xffffffffU
|
#define SP_MASK 0xffffffffU
|
||||||
#elif SP_WORD_SIZE == 64
|
#elif SP_WORD_SIZE == 64
|
||||||
|
#define SP_WORD_SIZEOF 8
|
||||||
|
|
||||||
typedef sp_uint64 sp_int_digit;
|
typedef sp_uint64 sp_int_digit;
|
||||||
typedef sp_int64 sp_int_sdigit;
|
typedef sp_int64 sp_int_sdigit;
|
||||||
#if (defined(WOLFSSL_SP_MATH) || defined(WOLFSSL_SP_MATH_ALL)) && \
|
#if (defined(WOLFSSL_SP_MATH) || defined(WOLFSSL_SP_MATH_ALL)) && \
|
||||||
@@ -917,7 +922,7 @@ typedef struct sp_int {
|
|||||||
struct WC_BIGINT raw;
|
struct WC_BIGINT raw;
|
||||||
#endif
|
#endif
|
||||||
/** Data of number. */
|
/** Data of number. */
|
||||||
XALIGNED(SP_WORD_SIZE / 8) sp_int_digit dp[SP_INT_DIGITS];
|
XALIGNED(SP_WORD_SIZEOF) sp_int_digit dp[SP_INT_DIGITS];
|
||||||
} sp_int;
|
} sp_int;
|
||||||
|
|
||||||
typedef struct sp_int_minimal {
|
typedef struct sp_int_minimal {
|
||||||
@@ -934,7 +939,7 @@ typedef struct sp_int_minimal {
|
|||||||
struct WC_BIGINT raw;
|
struct WC_BIGINT raw;
|
||||||
#endif
|
#endif
|
||||||
/** First digit of number. */
|
/** First digit of number. */
|
||||||
XALIGNED(SP_WORD_SIZE / 8) sp_int_digit dp[1];
|
XALIGNED(SP_WORD_SIZEOF) sp_int_digit dp[1];
|
||||||
} sp_int_minimal;
|
} sp_int_minimal;
|
||||||
|
|
||||||
/* MP_INT_SIZEOF_DIGITS() requires that sizeof(sp_int) is a multiple of
|
/* MP_INT_SIZEOF_DIGITS() requires that sizeof(sp_int) is a multiple of
|
||||||
|
Reference in New Issue
Block a user