提交 aacf29b8 编写于 作者: M Matt Caswell

Replace DECAF_INLINE with ossl_inline

Reviewed-by: NBernd Edlinger <bernd.edlinger@hotmail.de>
(Merged from https://github.com/openssl/openssl/pull/5105)
上级 88ba7e71
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include <stdint.h> #include <stdint.h>
#include <sys/types.h> #include <sys/types.h>
#include <openssl/e_os2.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
...@@ -28,7 +29,6 @@ extern "C" { ...@@ -28,7 +29,6 @@ extern "C" {
#define DECAF_NOINLINE __attribute__((noinline)) #define DECAF_NOINLINE __attribute__((noinline))
#define DECAF_WARN_UNUSED __attribute__((warn_unused_result)) #define DECAF_WARN_UNUSED __attribute__((warn_unused_result))
#define DECAF_NONNULL __attribute__((nonnull)) #define DECAF_NONNULL __attribute__((nonnull))
#define DECAF_INLINE inline __attribute__((always_inline,unused))
/** @endcond */ /** @endcond */
/* Internal word types. /* Internal word types.
...@@ -76,13 +76,13 @@ typedef enum { ...@@ -76,13 +76,13 @@ typedef enum {
/** Return success if x is true */ /** Return success if x is true */
static DECAF_INLINE decaf_error_t static ossl_inline decaf_error_t
decaf_succeed_if(decaf_bool_t x) { decaf_succeed_if(decaf_bool_t x) {
return (decaf_error_t)x; return (decaf_error_t)x;
} }
/** Return DECAF_TRUE iff x == DECAF_SUCCESS */ /** Return DECAF_TRUE iff x == DECAF_SUCCESS */
static DECAF_INLINE decaf_bool_t static ossl_inline decaf_bool_t
decaf_successful(decaf_error_t e) { decaf_successful(decaf_error_t e) {
decaf_dword_t w = ((decaf_word_t)e) ^ ((decaf_word_t)DECAF_SUCCESS); decaf_dword_t w = ((decaf_word_t)e) ^ ((decaf_word_t)DECAF_SUCCESS);
return (w-1)>>DECAF_WORD_BITS; return (w-1)>>DECAF_WORD_BITS;
......
...@@ -107,7 +107,7 @@ void curve448_point_double(curve448_point_t p, const curve448_point_t q) { ...@@ -107,7 +107,7 @@ void curve448_point_double(curve448_point_t p, const curve448_point_t q) {
} }
/* Operations on [p]niels */ /* Operations on [p]niels */
static DECAF_INLINE void static ossl_inline void
cond_neg_niels ( cond_neg_niels (
niels_t n, niels_t n,
mask_t neg mask_t neg
...@@ -247,7 +247,7 @@ decaf_bool_t curve448_point_valid ( ...@@ -247,7 +247,7 @@ decaf_bool_t curve448_point_valid (
return mask_to_bool(out); return mask_to_bool(out);
} }
static DECAF_INLINE void static ossl_inline void
constant_time_lookup_niels ( constant_time_lookup_niels (
niels_s *__restrict__ ni, niels_s *__restrict__ ni,
const niels_t *table, const niels_t *table,
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
#include <string.h> #include <string.h>
/** Square x, n times. */ /** Square x, n times. */
static DECAF_INLINE void gf_sqrn ( static ossl_inline void gf_sqrn (
gf_s *__restrict__ y, gf_s *__restrict__ y,
const gf x, const gf x,
int n int n
...@@ -80,11 +80,11 @@ gf_cond_swap(gf x, gf_s *__restrict__ y, mask_t swap) { ...@@ -80,11 +80,11 @@ gf_cond_swap(gf x, gf_s *__restrict__ y, mask_t swap) {
constant_time_cond_swap(x,y,sizeof(gf_s),swap); constant_time_cond_swap(x,y,sizeof(gf_s),swap);
} }
static DECAF_INLINE void gf_mul_qnr(gf_s *__restrict__ out, const gf x) { static ossl_inline void gf_mul_qnr(gf_s *__restrict__ out, const gf x) {
gf_sub(out,ZERO,x); gf_sub(out,ZERO,x);
} }
static DECAF_INLINE void gf_div_qnr(gf_s *__restrict__ out, const gf x) { static ossl_inline void gf_div_qnr(gf_s *__restrict__ out, const gf x) {
gf_sub(out,ZERO,x); gf_sub(out,ZERO,x);
} }
......
...@@ -126,7 +126,7 @@ void curve448_scalar_add ( ...@@ -126,7 +126,7 @@ void curve448_scalar_add (
sc_subx(out, out->limb, sc_p, sc_p, chain); sc_subx(out, out->limb, sc_p, sc_p, chain);
} }
static DECAF_INLINE void scalar_decode_short ( static ossl_inline void scalar_decode_short (
curve448_scalar_t s, curve448_scalar_t s,
const unsigned char *ser, const unsigned char *ser,
unsigned int nbytes unsigned int nbytes
......
...@@ -96,7 +96,7 @@ ...@@ -96,7 +96,7 @@
typedef uint64x4_t uint64xn_t; typedef uint64x4_t uint64xn_t;
typedef uint32x8_t uint32xn_t; typedef uint32x8_t uint32xn_t;
static DECAF_INLINE big_register_t static ossl_inline big_register_t
br_set_to_mask(mask_t x) { br_set_to_mask(mask_t x) {
uint32_t y = (uint32_t)x; uint32_t y = (uint32_t)x;
big_register_t ret = {y,y,y,y,y,y,y,y}; big_register_t ret = {y,y,y,y,y,y,y,y};
...@@ -108,7 +108,7 @@ ...@@ -108,7 +108,7 @@
typedef uint64x2_t uint64xn_t; typedef uint64x2_t uint64xn_t;
typedef uint32x4_t uint32xn_t; typedef uint32x4_t uint32xn_t;
static DECAF_INLINE big_register_t static ossl_inline big_register_t
br_set_to_mask(mask_t x) { br_set_to_mask(mask_t x) {
uint32_t y = x; uint32_t y = x;
big_register_t ret = {y,y,y,y}; big_register_t ret = {y,y,y,y};
...@@ -120,7 +120,7 @@ ...@@ -120,7 +120,7 @@
typedef uint64x2_t uint64xn_t; typedef uint64x2_t uint64xn_t;
typedef uint32x4_t uint32xn_t; typedef uint32x4_t uint32xn_t;
static DECAF_INLINE big_register_t static ossl_inline big_register_t
br_set_to_mask(mask_t x) { br_set_to_mask(mask_t x) {
return vdupq_n_u32(x); return vdupq_n_u32(x);
} }
...@@ -129,7 +129,7 @@ ...@@ -129,7 +129,7 @@
typedef uint64_t big_register_t, uint64xn_t; typedef uint64_t big_register_t, uint64xn_t;
typedef uint32_t uint32xn_t; typedef uint32_t uint32xn_t;
static DECAF_INLINE big_register_t static ossl_inline big_register_t
br_set_to_mask(mask_t x) { br_set_to_mask(mask_t x) {
return (big_register_t)x; return (big_register_t)x;
} }
...@@ -139,25 +139,25 @@ ...@@ -139,25 +139,25 @@
typedef uint32_t uint32xn_t; typedef uint32_t uint32xn_t;
typedef uint32_t big_register_t; typedef uint32_t big_register_t;
static DECAF_INLINE big_register_t static ossl_inline big_register_t
br_set_to_mask(mask_t x) { br_set_to_mask(mask_t x) {
return (big_register_t)x; return (big_register_t)x;
} }
#endif #endif
#if __AVX2__ #if __AVX2__
static DECAF_INLINE big_register_t static ossl_inline big_register_t
br_is_zero(big_register_t x) { br_is_zero(big_register_t x) {
return (big_register_t)(x == br_set_to_mask(0)); return (big_register_t)(x == br_set_to_mask(0));
} }
#elif __SSE2__ #elif __SSE2__
static DECAF_INLINE big_register_t static ossl_inline big_register_t
br_is_zero(big_register_t x) { br_is_zero(big_register_t x) {
return (big_register_t)_mm_cmpeq_epi32((__m128i)x, _mm_setzero_si128()); return (big_register_t)_mm_cmpeq_epi32((__m128i)x, _mm_setzero_si128());
//return (big_register_t)(x == br_set_to_mask(0)); //return (big_register_t)(x == br_set_to_mask(0));
} }
#elif __ARM_NEON__ #elif __ARM_NEON__
static DECAF_INLINE big_register_t static ossl_inline big_register_t
br_is_zero(big_register_t x) { br_is_zero(big_register_t x) {
return vceqq_u32(x,x^x); return vceqq_u32(x,x^x);
} }
...@@ -189,11 +189,11 @@ ...@@ -189,11 +189,11 @@
* On the third hand, we have success vs boolean types, but that's handled in * On the third hand, we have success vs boolean types, but that's handled in
* common.h: it converts between decaf_bool_t and decaf_error_t. * common.h: it converts between decaf_bool_t and decaf_error_t.
*/ */
static DECAF_INLINE decaf_bool_t mask_to_bool (mask_t m) { static ossl_inline decaf_bool_t mask_to_bool (mask_t m) {
return (decaf_sword_t)(sword_t)m; return (decaf_sword_t)(sword_t)m;
} }
static DECAF_INLINE mask_t bool_to_mask (decaf_bool_t m) { static ossl_inline mask_t bool_to_mask (decaf_bool_t m) {
/* On most arches this will be optimized to a simple cast. */ /* On most arches this will be optimized to a simple cast. */
mask_t ret = 0; mask_t ret = 0;
unsigned int limit = sizeof(decaf_bool_t)/sizeof(mask_t); unsigned int limit = sizeof(decaf_bool_t)/sizeof(mask_t);
...@@ -204,7 +204,7 @@ static DECAF_INLINE mask_t bool_to_mask (decaf_bool_t m) { ...@@ -204,7 +204,7 @@ static DECAF_INLINE mask_t bool_to_mask (decaf_bool_t m) {
return ret; return ret;
} }
static DECAF_INLINE void ignore_result ( decaf_bool_t boo ) { static ossl_inline void ignore_result ( decaf_bool_t boo ) {
(void)boo; (void)boo;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册