mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2026-05-04 17:12:51 +02:00
Unify the detection of Unix-like platforms
We were using slightly different guards to decide whether to include `<unistd.h>` in different places. Unify those. Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
3
ChangeLog.d/unistd.txt
Normal file
3
ChangeLog.d/unistd.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
Changes
|
||||
* Tweak the detection of Unix-like platforms, which makes more system
|
||||
interfaces (timing, threading) available on Haiku, QNX and Midipix.
|
||||
@@ -27,6 +27,21 @@
|
||||
#define MBEDTLS_HAVE_NEON_INTRINSICS
|
||||
#endif
|
||||
|
||||
/* Decide whether we're built for a Unix-like platform.
|
||||
*/
|
||||
#if defined(_WIN32)
|
||||
/* If Windows platform interfaces are available, we use them, even if
|
||||
* a Unix-like might also to be available. */
|
||||
/* defined(_WIN32) ==> we can include <windows.h> */
|
||||
#elif defined(unix) || defined(__unix) || defined(__unix__) || \
|
||||
(defined(__APPLE__) && defined(__MACH__)) || \
|
||||
defined(__HAIKU__) || \
|
||||
defined(__midipix__) || \
|
||||
/* Add other Unix-like platform indicators here ^^^^ */ 0
|
||||
/* defined(MBEDTLS_PLATFORM_IS_UNIXLIKE) ==> we can include <unistd.h> */
|
||||
#define MBEDTLS_PLATFORM_IS_UNIXLIKE
|
||||
#endif
|
||||
|
||||
/** Helper to define a function as static except when building invasive tests.
|
||||
*
|
||||
* If a function is only used inside its own source file and should be
|
||||
|
||||
@@ -19,9 +19,7 @@
|
||||
|
||||
#if defined(MBEDTLS_NET_C)
|
||||
|
||||
#if !defined(unix) && !defined(__unix__) && !defined(__unix) && \
|
||||
!defined(__APPLE__) && !defined(_WIN32) && !defined(__QNXNTO__) && \
|
||||
!defined(__HAIKU__) && !defined(__midipix__)
|
||||
#if !defined(MBEDTLS_PLATFORM_IS_UNIXLIKE) && !defined(_WIN32)
|
||||
#error "This module only works on Unix and Windows, see MBEDTLS_NET_C in mbedtls_config.h"
|
||||
#endif
|
||||
|
||||
|
||||
@@ -147,12 +147,9 @@ void mbedtls_zeroize_and_free(void *buf, size_t len)
|
||||
|
||||
#if defined(MBEDTLS_HAVE_TIME_DATE) && !defined(MBEDTLS_PLATFORM_GMTIME_R_ALT)
|
||||
#include <time.h>
|
||||
#if !defined(_WIN32) && (defined(unix) || \
|
||||
defined(__unix) || defined(__unix__) || (defined(__APPLE__) && \
|
||||
defined(__MACH__)) || defined(__midipix__))
|
||||
#if defined(MBEDTLS_PLATFORM_IS_UNIXLIKE)
|
||||
#include <unistd.h>
|
||||
#endif /* !_WIN32 && (unix || __unix || __unix__ ||
|
||||
* (__APPLE__ && __MACH__) || __midipix__) */
|
||||
#endif
|
||||
|
||||
#if !((defined(_POSIX_VERSION) && _POSIX_VERSION >= 200809L) || \
|
||||
(defined(_POSIX_THREAD_SAFE_FUNCTIONS) && \
|
||||
@@ -218,12 +215,10 @@ void (*mbedtls_test_hook_test_fail)(const char *, int, const char *);
|
||||
#if defined(MBEDTLS_HAVE_TIME) && !defined(MBEDTLS_PLATFORM_MS_TIME_ALT)
|
||||
|
||||
#include <time.h>
|
||||
#if !defined(_WIN32) && \
|
||||
(defined(unix) || defined(__unix) || defined(__unix__) || \
|
||||
(defined(__APPLE__) && defined(__MACH__)) || defined(__HAIKU__) || defined(__midipix__))
|
||||
#if defined(MBEDTLS_PLATFORM_IS_UNIXLIKE)
|
||||
#include <unistd.h>
|
||||
#endif \
|
||||
/* !_WIN32 && (unix || __unix || __unix__ || (__APPLE__ && __MACH__) || __HAIKU__ || __midipix__) */
|
||||
#endif
|
||||
|
||||
#if (defined(_POSIX_VERSION) && _POSIX_VERSION >= 199309L) || defined(__HAIKU__)
|
||||
mbedtls_ms_time_t mbedtls_ms_time(void)
|
||||
{
|
||||
|
||||
@@ -21,9 +21,7 @@
|
||||
|
||||
#if defined(MBEDTLS_HAVE_TIME_DATE) && !defined(MBEDTLS_PLATFORM_GMTIME_R_ALT)
|
||||
|
||||
#if !defined(_WIN32) && (defined(unix) || \
|
||||
defined(__unix) || defined(__unix__) || (defined(__APPLE__) && \
|
||||
defined(__MACH__)))
|
||||
#if defined(MBEDTLS_PLATFORM_IS_UNIXLIKE)
|
||||
#include <unistd.h>
|
||||
#endif /* !_WIN32 && (unix || __unix || __unix__ ||
|
||||
* (__APPLE__ && __MACH__)) */
|
||||
|
||||
@@ -13,9 +13,7 @@
|
||||
|
||||
#if !defined(MBEDTLS_TIMING_ALT)
|
||||
|
||||
#if !defined(unix) && !defined(__unix__) && !defined(__unix) && \
|
||||
!defined(__APPLE__) && !defined(_WIN32) && !defined(__QNXNTO__) && \
|
||||
!defined(__HAIKU__) && !defined(__midipix__)
|
||||
#if !defined(_WIN32) && !defined(MBEDTLS_PLATFORM_IS_UNIXLIKE)
|
||||
#error "This module only works on Unix and Windows, see MBEDTLS_TIMING_C in mbedtls_config.h"
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user