Move MIN and MAX macros from PSA tests to helpers.function

This commit is contained in:
Gilles Peskine 2018-12-18 08:47:00 +01:00
parent d76f181617
commit c08fc1d7e9
4 changed files with 17 additions and 10 deletions

View file

@ -202,6 +202,23 @@ typedef struct data_tag
( STATIC_ASSERT_THEN_RETURN( IS_ARRAY_NOT_POINTER( array ), \
ARRAY_LENGTH_UNSAFE( array ) ) )
/** Return the smaller of two values.
*
* \param x An integer-valued expression without side effects.
* \param y An integer-valued expression without side effects.
*
* \return The smaller of \p x and \p y.
*/
#define MIN( x, y ) ( ( x ) < ( y ) ? ( x ) : ( y ) )
/** Return the larger of two values.
*
* \param x An integer-valued expression without side effects.
* \param y An integer-valued expression without side effects.
*
* \return The larger of \p x and \p y.
*/
#define MAX( x, y ) ( ( x ) > ( y ) ? ( x ) : ( y ) )
/*
* 32-bit integer manipulation macros (big endian)

View file

@ -11,8 +11,6 @@
#include "psa/crypto.h"
#define MAX( x, y ) ( ( x ) > ( y ) ? ( x ) : ( y ) )
/** An invalid export length that will never be set by psa_export_key(). */
static const size_t INVALID_EXPORT_LENGTH = ~0U;

View file

@ -6,11 +6,6 @@
#include "mbedtls/entropy.h"
#include "mbedtls/entropy_poll.h"
/* MAX value support macro */
#if !defined(MAX)
#define MAX(a,b) (((a)>(b))?(a):(b))
#endif
/* Calculating the minimum allowed entropy size in bytes */
#define MBEDTLS_PSA_INJECT_ENTROPY_MIN_SIZE MAX(MBEDTLS_ENTROPY_MIN_PLATFORM, MBEDTLS_ENTROPY_BLOCK_SIZE)

View file

@ -12,9 +12,6 @@
#include "mbedtls/entropy.h"
#include "mbedtls/entropy_poll.h"
#define MIN( x, y ) ( ( x ) < ( y ) ? ( x ) : ( y ) )
#define MAX( x, y ) ( ( x ) > ( y ) ? ( x ) : ( y ) )
#define ENTROPY_MIN_NV_SEED_SIZE \
MAX(MBEDTLS_ENTROPY_MIN_PLATFORM, MBEDTLS_ENTROPY_BLOCK_SIZE)