Create a header to declare platform requirements

On some platforms, the system headers expose different interfaces depending
on what macros are defined, for example to provide different standards
compliance level. Create a common place where we can declare such macros,
so that our code can behave in the same way when it's in different files.
Individual .c files can still override these requirements by defining
macros before including the common header, if it's really necessary.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
Gilles Peskine
2026-01-29 16:25:15 +01:00
parent 29d00fa861
commit 3a98885950
2 changed files with 28 additions and 0 deletions

View File

@@ -11,6 +11,16 @@
#ifndef MBEDTLS_MBEDTLS_COMMON_H
#define MBEDTLS_MBEDTLS_COMMON_H
/* Before including any system header, declare some macros to tell system
* headers what we expect of them.
*
* Do this before including any header from TF-PSA-Crypto, since the
* convention is first-come-first-served (so that users can
* override some macros on the command line, and individual users can
* override some macros before including the common header).
*/
#include "mbedtls_platform_requirements.h"
/* Mbed TLS requires TF-PSA-Crypto internals. */
#include "tf_psa_crypto_common.h"

View File

@@ -0,0 +1,18 @@
/**
* \file mbedtls_platform_requirements.h
*
* \brief Declare macros that tell system headers what we expect of them.
*
* This file must be included before any system header, and so in particular
* before build_info.h (which includes the user config, which may include
* system headers).
*/
/*
* Copyright The Mbed TLS Contributors
* SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
*/
#ifndef MBEDTLS_MBEDTLS_PLATFORM_REQUIREMENTS_H
#define MBEDTLS_MBEDTLS_PLATFORM_REQUIREMENTS_H
#endif /* MBEDTLS_MBEDTLS_PLATFORM_REQUIREMENTS_H */