From 754d1274a7ed9a96b84d66e107bd21ae042cc337 Mon Sep 17 00:00:00 2001 From: Peter Bigot Date: Mon, 12 Aug 2019 16:40:47 -0500 Subject: [PATCH] include/net: additional cleanup for extern "C" use The previous patch left some include directives hidden within the body of the extern "C" block. Lift them out to the top of the file where they're more visible. Signed-off-by: Peter Bigot --- include/net/ethernet.h | 8 ++++---- include/net/net_core.h | 14 ++++++-------- include/net/net_mgmt.h | 3 +-- include/net/net_stats.h | 3 +-- include/net/socket.h | 5 +++++ 5 files changed, 17 insertions(+), 16 deletions(-) diff --git a/include/net/ethernet.h b/include/net/ethernet.h index f363a7bb55a..713265c77ab 100644 --- a/include/net/ethernet.h +++ b/include/net/ethernet.h @@ -722,14 +722,14 @@ static inline int net_eth_get_ptp_port(struct net_if *iface) void net_eth_set_ptp_port(struct net_if *iface, int port); #endif /* CONFIG_NET_GPTP */ -#include +/** + * @} + */ #ifdef __cplusplus } #endif -/** - * @} - */ +#include #endif /* ZEPHYR_INCLUDE_NET_ETHERNET_H_ */ diff --git a/include/net/net_core.h b/include/net/net_core.h index 377bc6fee31..508f11c15b7 100644 --- a/include/net/net_core.h +++ b/include/net/net_core.h @@ -14,6 +14,11 @@ #define ZEPHYR_INCLUDE_NET_NET_CORE_H_ #include +#include + +#include +#include +#include #ifdef __cplusplus extern "C" { @@ -36,30 +41,22 @@ extern "C" { /** @cond INTERNAL_HIDDEN */ /* Network subsystem logging helpers */ -#include - #define NET_DBG(fmt, ...) LOG_DBG("(%p): " fmt, k_current_get(), \ ##__VA_ARGS__) #define NET_ERR(fmt, ...) LOG_ERR(fmt, ##__VA_ARGS__) #define NET_WARN(fmt, ...) LOG_WRN(fmt, ##__VA_ARGS__) #define NET_INFO(fmt, ...) LOG_INF(fmt, ##__VA_ARGS__) -#include - #define NET_ASSERT(cond) __ASSERT_NO_MSG(cond) #define NET_ASSERT_INFO(cond, fmt, ...) __ASSERT(cond, fmt, ##__VA_ARGS__) /** @endcond */ -#include - struct net_buf; struct net_pkt; struct net_context; struct net_if; -#include - /** * @brief Net Verdict */ @@ -187,6 +184,7 @@ struct net_stack_info { #define NET_STACK_DEFINE_EMBEDDED(name, size) char name[size] #if defined(CONFIG_INIT_STACKS) +/* Legacy case: retain containing extern "C" with C++ */ #include static inline void net_analyze_stack_get_values(const char *stack, diff --git a/include/net/net_mgmt.h b/include/net/net_mgmt.h index 9b5c43ed349..ea18557021b 100644 --- a/include/net/net_mgmt.h +++ b/include/net/net_mgmt.h @@ -14,6 +14,7 @@ #include #include +#include #ifdef __cplusplus extern "C" { @@ -72,8 +73,6 @@ struct net_if; /** @endcond */ -#include - /** * @typedef net_mgmt_request_handler_t diff --git a/include/net/net_stats.h b/include/net/net_stats.h index f2326c5840a..0d0bf826150 100644 --- a/include/net/net_stats.h +++ b/include/net/net_stats.h @@ -16,6 +16,7 @@ #include #include +#include #ifdef __cplusplus extern "C" { @@ -393,8 +394,6 @@ struct net_stats_ppp { #if defined(CONFIG_NET_STATISTICS_USER_API) /* Management part definitions */ -#include - #define _NET_STATS_LAYER NET_MGMT_LAYER_L3 #define _NET_STATS_CODE 0x101 #define _NET_STATS_BASE (NET_MGMT_LAYER(_NET_STATS_LAYER) | \ diff --git a/include/net/socket.h b/include/net/socket.h index 96e00588239..72a8187015a 100644 --- a/include/net/socket.h +++ b/include/net/socket.h @@ -697,6 +697,11 @@ struct addrinfo { struct addrinfo *ai_next; }; +/* Legacy case: retain containing extern "C" with C++ + * + * This header requires aliases defined within this file, and can't + * easily be moved to the top. + */ #include static inline int inet_pton(sa_family_t family, const char *src, void *dst)