diff --git a/library/mbedtls_platform_requirements.h b/library/mbedtls_platform_requirements.h index c86204e6fa..c4f959191f 100644 --- a/library/mbedtls_platform_requirements.h +++ b/library/mbedtls_platform_requirements.h @@ -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 diff --git a/library/net_sockets.c b/library/net_sockets.c index 25f06824cb..404ef761ae 100644 --- a/library/net_sockets.c +++ b/library/net_sockets.c @@ -5,16 +5,6 @@ * 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)