From cfeb70c6b98d489dd3a7de5b1523abe44ccd5793 Mon Sep 17 00:00:00 2001 From: Hanno Becker Date: Wed, 5 Sep 2018 13:50:22 +0100 Subject: [PATCH] gmtime: Remove special treatment for IAR Previous commits attempted to use `gmtime_s()` for IAR systems; however, this attempt depends on the use of C11 extensions which lead to incompatibility with other pieces of the library, such as the use of `memset()` which is being deprecated in favor of `memset_s()` in C11. --- ChangeLog | 4 ++-- include/mbedtls/threading.h | 4 ++-- library/platform_util.c | 6 ++---- library/threading.c | 4 ++-- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1ba5f0e00..0a60f70fe 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,8 +7,8 @@ API Changes whose implementation should behave as a thread safe version of gmtime(). This allows users to configure such an implementation at compile time when the target system cannot be deduced automatically. At this stage Mbed TLS - is only able to automatically select implementations for Windows, POSIX - C libraries and IAR. + is only able to automatically select implementations for Windows and POSIX + C libraries. Bugfix * Fixes an issue with MBEDTLS_CHACHAPOLY_C which would not compile if diff --git a/include/mbedtls/threading.h b/include/mbedtls/threading.h index 1b13deb3e..a65eefa92 100644 --- a/include/mbedtls/threading.h +++ b/include/mbedtls/threading.h @@ -108,7 +108,7 @@ extern int (*mbedtls_mutex_unlock)( mbedtls_threading_mutex_t *mutex ); extern mbedtls_threading_mutex_t mbedtls_threading_readdir_mutex; #endif #if defined(MBEDTLS_HAVE_TIME_DATE) -#if !defined(_WIN32) && !defined(__IAR_SYSTEMS_ICC__) && (defined(unix) || \ +#if !defined(_WIN32) && (defined(unix) || \ defined(__unix) || defined(__unix__) || (defined(__APPLE__) && \ defined(__MACH__))) #include @@ -120,7 +120,7 @@ extern mbedtls_threading_mutex_t mbedtls_threading_readdir_mutex; */ extern mbedtls_threading_mutex_t mbedtls_threading_gmtime_mutex; #endif /* !_POSIX_VERSION || 200112L > _POSIX_THREAD_SAFE_FUNCTIONS */ -#endif /* !_WIN32 && !__IAR_SYSTEMS_ICC__ && (unix || __unix || __unix__ || +#endif /* !_WIN32 && (unix || __unix || __unix__ || * (__APPLE__ && __MACH__)) */ #endif /* MBEDTLS_HAVE_TIME_DATE */ #endif /* MBEDTLS_THREADING_C */ diff --git a/library/platform_util.c b/library/platform_util.c index 6a5feb321..c248cf529 100644 --- a/library/platform_util.c +++ b/library/platform_util.c @@ -77,7 +77,7 @@ void mbedtls_platform_zeroize( void *buf, size_t len ) #if defined(MBEDTLS_HAVE_TIME_DATE) && !defined(MBEDTLS_PLATFORM_GMTIME_ALT) #include -#if !defined(_WIN32) && !defined(__IAR_SYSTEMS_ICC__) && (defined(unix) || \ +#if !defined(_WIN32) && (defined(unix) || \ defined(__unix) || defined(__unix__) || (defined(__APPLE__) && \ defined(__MACH__))) #include @@ -91,7 +91,7 @@ void mbedtls_platform_zeroize( void *buf, size_t len ) */ #define PLATFORM_UTIL_USE_GMTIME #endif /* !_POSIX_VERSION || _POSIX_C_SOURCE > _POSIX_THREAD_SAFE_FUNCTIONS */ -#endif /* !_WIN32 && !__IAR_SYSTEMS_ICC__ && (unix || __unix || __unix__ || +#endif /* !_WIN32 && (unix || __unix || __unix__ || * (__APPLE__ && __MACH__)) */ struct tm *mbedtls_platform_gmtime( const mbedtls_time_t *tt, @@ -99,8 +99,6 @@ struct tm *mbedtls_platform_gmtime( const mbedtls_time_t *tt, { #if defined(_WIN32) && !defined(EFIX64) && !defined(EFI32) return( ( gmtime_s( tm_buf, tt ) == 0 ) ? tm_buf : NULL ); -#elif defined(__IAR_SYSTEMS_ICC__) - return( gmtime_s( tt, tm_buf ) ); #elif !defined(PLATFORM_UTIL_USE_GMTIME) return( gmtime_r( tt, tm_buf ) ); #else diff --git a/library/threading.c b/library/threading.c index c1834bace..9d5c4f104 100644 --- a/library/threading.c +++ b/library/threading.c @@ -37,7 +37,7 @@ #include "mbedtls/threading.h" -#if !defined(_WIN32) && !defined(__IAR_SYSTEMS_ICC__) && (defined(unix) || \ +#if !defined(_WIN32) && (defined(unix) || \ defined(__unix) || defined(__unix__) || (defined(__APPLE__) && \ defined(__MACH__))) #include @@ -51,7 +51,7 @@ */ #define THREADING_USE_GMTIME #endif /* !_POSIX_VERSION || 200112L > _POSIX_THREAD_SAFE_FUNCTIONS */ -#endif /* !_WIN32 && !__IAR_SYSTEMS_ICC__ && (unix || __unix || __unix__ || +#endif /* !_WIN32 && (unix || __unix || __unix__ || * (__APPLE__ && __MACH__)) */ #if defined(MBEDTLS_THREADING_PTHREAD)