Merge pull request #3574 from makise-homura/e2k_support

Support building on e2k (Elbrus) architecture
This commit is contained in:
Gilles Peskine 2020-08-25 09:46:36 +02:00 committed by GitHub
commit ed19762a22
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 15 additions and 5 deletions

View File

@ -152,6 +152,8 @@ endfunction(link_to_source)
string(REGEX MATCH "Clang" CMAKE_COMPILER_IS_CLANG "${CMAKE_C_COMPILER_ID}") string(REGEX MATCH "Clang" CMAKE_COMPILER_IS_CLANG "${CMAKE_C_COMPILER_ID}")
include(CheckCCompilerFlag)
if(CMAKE_COMPILER_IS_GNU) if(CMAKE_COMPILER_IS_GNU)
# some warnings we want are not available with old GCC versions # some warnings we want are not available with old GCC versions
# note: starting with CMake 2.8 we could use CMAKE_C_COMPILER_VERSION # note: starting with CMake 2.8 we could use CMAKE_C_COMPILER_VERSION
@ -168,7 +170,10 @@ if(CMAKE_COMPILER_IS_GNU)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wshadow") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wshadow")
endif() endif()
if (GCC_VERSION VERSION_GREATER 5.0) if (GCC_VERSION VERSION_GREATER 5.0)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wformat-signedness") CHECK_C_COMPILER_FLAG("-Wformat-signedness" C_COMPILER_SUPPORTS_WFORMAT_SIGNEDNESS)
if(C_COMPILER_SUPPORTS_WFORMAT_SIGNEDNESS)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wformat-signedness")
endif()
endif() endif()
set(CMAKE_C_FLAGS_RELEASE "-O2") set(CMAKE_C_FLAGS_RELEASE "-O2")
set(CMAKE_C_FLAGS_DEBUG "-O0 -g3") set(CMAKE_C_FLAGS_DEBUG "-O0 -g3")

View File

@ -0,0 +1,5 @@
Features
* Support building on e2k (Elbrus) architecture: correctly enable
-Wformat-signedness, and fix the code that causes signed-one-bit-field
and sign-compare warnings. Contributed by makise-homura (Igor Molchanov)
<akemi_homura@kurisa.ch>.

View File

@ -2046,7 +2046,7 @@ int mbedtls_ssl_fetch_input( mbedtls_ssl_context *ssl, size_t nb_want )
if( ret < 0 ) if( ret < 0 )
return( ret ); return( ret );
if ( (size_t)ret > len || ( INT_MAX > SIZE_MAX && ret > SIZE_MAX ) ) if ( (size_t)ret > len || ( INT_MAX > SIZE_MAX && ret > (int)SIZE_MAX ) )
{ {
MBEDTLS_SSL_DEBUG_MSG( 1, MBEDTLS_SSL_DEBUG_MSG( 1,
( "f_recv returned %d bytes but only %lu were requested", ( "f_recv returned %d bytes but only %lu were requested",
@ -2100,7 +2100,7 @@ int mbedtls_ssl_flush_output( mbedtls_ssl_context *ssl )
if( ret <= 0 ) if( ret <= 0 )
return( ret ); return( ret );
if( (size_t)ret > ssl->out_left || ( INT_MAX > SIZE_MAX && ret > SIZE_MAX ) ) if( (size_t)ret > ssl->out_left || ( INT_MAX > SIZE_MAX && ret > (int)SIZE_MAX ) )
{ {
MBEDTLS_SSL_DEBUG_MSG( 1, MBEDTLS_SSL_DEBUG_MSG( 1,
( "f_send returned %d bytes but only %lu bytes were sent", ( "f_send returned %d bytes but only %lu bytes were sent",

View File

@ -89,7 +89,7 @@ int main( int argc, char **argv )
{ {
usage: usage:
mbedtls_printf( USAGE ); mbedtls_printf( USAGE );
mbedtls_exit( exit_code ); goto exit;
} }
for( i = 1; i < argc; i++ ) for( i = 1; i < argc; i++ )

View File

@ -73,7 +73,7 @@
/* A compile-time constant with the value 0. If `const_expr` is not a /* A compile-time constant with the value 0. If `const_expr` is not a
* compile-time constant with a nonzero value, cause a compile-time error. */ * compile-time constant with a nonzero value, cause a compile-time error. */
#define STATIC_ASSERT_EXPR( const_expr ) \ #define STATIC_ASSERT_EXPR( const_expr ) \
( 0 && sizeof( struct { int STATIC_ASSERT : 1 - 2 * ! ( const_expr ); } ) ) ( 0 && sizeof( struct { unsigned int STATIC_ASSERT : 1 - 2 * ! ( const_expr ); } ) )
/* Return the scalar value `value` (possibly promoted). This is a compile-time /* Return the scalar value `value` (possibly promoted). This is a compile-time
* constant if `value` is. `condition` must be a compile-time constant. * constant if `value` is. `condition` must be a compile-time constant.
* If `condition` is false, arrange to cause a compile-time error. */ * If `condition` is false, arrange to cause a compile-time error. */