Merge pull request #10606 from gilles-peskine-arm/unix-detection-202601-4.0

Simplify platform requirements before 4.1
This commit is contained in:
Gilles Peskine
2026-03-06 18:06:08 +00:00
committed by GitHub
9 changed files with 72 additions and 14 deletions

3
ChangeLog.d/unistd.txt Normal file
View 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.

View File

@@ -33,6 +33,14 @@
*/
#include "mbedtls_platform_requirements.h"
/* Mbed TLS is tightly coupled with TF-PSA-Crypto, and inherits all of
* its platform requirements because we don't have a clear separation of
* public vs private platform interfaces. So make sure we declare the
* TF-PSA-Crypto platform requirements. We need to do that before including
* any system headers, thus before including the user config file since it
* may include platform headers. */
#include "tf_psa_crypto_platform_requirements.h"
/* From this point onwards, ensure we have the library configuration and
* the configuration-derived macros. */
#include <mbedtls/build_info.h>

View File

@@ -15,6 +15,20 @@
#ifndef MBEDTLS_MBEDTLS_PLATFORM_REQUIREMENTS_H
#define MBEDTLS_MBEDTLS_PLATFORM_REQUIREMENTS_H
#if !defined(_POSIX_C_SOURCE)
/* For standards-compliant access to
* getaddrinfo(),
* ... */
#define _POSIX_C_SOURCE 200112L
#endif
#if !defined(_XOPEN_SOURCE)
/* For standards-compliant access to
* sockaddr_storage,
* ... */
#define _XOPEN_SOURCE 600
#endif
/* On Mingw-w64, force the use of a C99-compliant printf() and friends.
* This is necessary on older versions of Mingw and/or Windows runtimes
* where snprintf does not always zero-terminate the buffer, and does
@@ -29,4 +43,13 @@
#define __USE_MINGW_ANSI_STDIO 1
#endif
/* Tell MSVC that we're ok with using classic C functions even
* when an `_s` variant exist. For most functions, the improvements
* of the `_s` variants are of limited usefulness and not worth
* the portability headaches.
*/
#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE)
#define _CRT_SECURE_NO_DEPRECATE 1
#endif
#endif /* MBEDTLS_MBEDTLS_PLATFORM_REQUIREMENTS_H */

View File

@@ -5,23 +5,11 @@
* SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
*/
/* Enable definition of getaddrinfo() even when compiling with -std=c99. Must
* be set before mbedtls_config.h, which pulls in glibc's features.h indirectly.
* Harmless on other platforms. */
#ifndef _POSIX_C_SOURCE
#define _POSIX_C_SOURCE 200112L
#endif
#ifndef _XOPEN_SOURCE
#define _XOPEN_SOURCE 600 /* sockaddr_storage */
#endif
#include "ssl_misc.h"
#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

View File

@@ -17,6 +17,15 @@
#define __USE_MINGW_ANSI_STDIO 1
#endif
/* Tell MSVC that we're ok with using classic C functions even
* when an `_s` variant exist. For most functions, the improvements
* of the `_s` variants are of limited usefulness and not worth
* the portability headaches.
*/
#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE)
#define _CRT_SECURE_NO_DEPRECATE 1
#endif
#define MBEDTLS_ALLOW_PRIVATE_ACCESS
#include "mbedtls/private/pk_private.h"

View File

@@ -5,6 +5,15 @@
* SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
*/
/* Tell MSVC that we're ok with using classic C functions even
* when an `_s` variant exist. For most functions, the improvements
* of the `_s` variants are of limited usefulness and not worth
* the portability headaches.
*/
#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE)
#define _CRT_SECURE_NO_DEPRECATE 1
#endif
#include "mbedtls/build_info.h"
#include "mbedtls/platform.h"

View File

@@ -5,6 +5,15 @@
* SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
*/
/* Tell MSVC that we're ok with using classic C functions even
* when an `_s` variant exist. For most functions, the improvements
* of the `_s` variants are of limited usefulness and not worth
* the portability headaches.
*/
#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE)
#define _CRT_SECURE_NO_DEPRECATE 1
#endif
#define MBEDTLS_DECLARE_PRIVATE_IDENTIFIERS
#include "mbedtls/build_info.h"

View File

@@ -5,6 +5,15 @@
* SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
*/
/* Tell MSVC that we're ok with using classic C functions even
* when an `_s` variant exist. For most functions, the improvements
* of the `_s` variants are of limited usefulness and not worth
* the portability headaches.
*/
#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE)
#define _CRT_SECURE_NO_DEPRECATE 1
#endif
#define MBEDTLS_DECLARE_PRIVATE_IDENTIFIERS
#include "mbedtls/build_info.h"