From ddf9b144cec950fbf63e9ef7b50669c5a6a78320 Mon Sep 17 00:00:00 2001 From: Peter Bigot Date: Mon, 12 Aug 2019 12:55:33 -0500 Subject: [PATCH] soc/arm/nxp*: rearrange for standard use of extern "C" Consistently place C++ use of extern "C" after all include directives, within the negative branch of _ASMLANGUAGE if used. Remove extern "C" support from files that don't declare objects or functions. Background from issue #17997: Declarations that use C linkage should be placed within extern "C" so the language linkage is correct when the header is included by a C++ compiler. Similarly #include directives should be outside the extern "C" to ensure the language-specific default linkage is applied to any declarations provided by the included header. See: https://en.cppreference.com/w/cpp/language/language_linkage Signed-off-by: Peter Bigot --- soc/arm/nxp_imx/mcimx6x_m4/soc.h | 8 -------- soc/arm/nxp_imx/mcimx7_m4/soc.h | 8 -------- soc/arm/nxp_imx/rt/soc.h | 12 ++++++------ soc/arm/nxp_kinetis/k6x/soc.h | 8 -------- soc/arm/nxp_kinetis/kl2x/soc.h | 8 -------- soc/arm/nxp_kinetis/kwx/soc.h | 8 -------- soc/arm/nxp_lpc/lpc54xxx/soc.h | 8 -------- soc/arm/nxp_lpc/lpc55xxx/soc.h | 8 -------- 8 files changed, 6 insertions(+), 62 deletions(-) diff --git a/soc/arm/nxp_imx/mcimx6x_m4/soc.h b/soc/arm/nxp_imx/mcimx6x_m4/soc.h index 92bba5fe325..33679cb1842 100644 --- a/soc/arm/nxp_imx/mcimx6x_m4/soc.h +++ b/soc/arm/nxp_imx/mcimx6x_m4/soc.h @@ -7,10 +7,6 @@ #ifndef _SOC__H_ #define _SOC__H_ -#ifdef __cplusplus -extern "C" { -#endif - #ifndef _ASMLANGUAGE #include "rdc.h" @@ -20,8 +16,4 @@ extern "C" { #endif /* !_ASMLANGUAGE */ -#ifdef __cplusplus -} -#endif - #endif /* _SOC__H_ */ diff --git a/soc/arm/nxp_imx/mcimx7_m4/soc.h b/soc/arm/nxp_imx/mcimx7_m4/soc.h index 43c87075268..5f9540084b6 100644 --- a/soc/arm/nxp_imx/mcimx7_m4/soc.h +++ b/soc/arm/nxp_imx/mcimx7_m4/soc.h @@ -7,10 +7,6 @@ #ifndef _SOC__H_ #define _SOC__H_ -#ifdef __cplusplus -extern "C" { -#endif - #ifndef _ASMLANGUAGE #include "rdc.h" @@ -21,8 +17,4 @@ extern "C" { #endif /* !_ASMLANGUAGE */ -#ifdef __cplusplus -} -#endif - #endif /* _SOC__H_ */ diff --git a/soc/arm/nxp_imx/rt/soc.h b/soc/arm/nxp_imx/rt/soc.h index 9206c215aad..2960732ae58 100644 --- a/soc/arm/nxp_imx/rt/soc.h +++ b/soc/arm/nxp_imx/rt/soc.h @@ -9,10 +9,6 @@ #include -#ifdef __cplusplus -extern "C" { -#endif - #ifndef _ASMLANGUAGE #include @@ -23,6 +19,10 @@ extern "C" { */ #include +#ifdef __cplusplus +extern "C" { +#endif + #if defined(CONFIG_DISK_ACCESS_USDHC1) || \ defined(CONFIG_DISK_ACCESS_USDHC2) @@ -36,10 +36,10 @@ void imxrt_usdhc_pinmux_cb_register(usdhc_pin_cfg_cb cb); #endif -#endif /* !_ASMLANGUAGE */ - #ifdef __cplusplus } #endif +#endif /* !_ASMLANGUAGE */ + #endif /* _SOC__H_ */ diff --git a/soc/arm/nxp_kinetis/k6x/soc.h b/soc/arm/nxp_kinetis/k6x/soc.h index 37e299208a1..d3fc56077f9 100644 --- a/soc/arm/nxp_kinetis/k6x/soc.h +++ b/soc/arm/nxp_kinetis/k6x/soc.h @@ -17,10 +17,6 @@ #include -#ifdef __cplusplus -extern "C" { -#endif - /* default system clock */ #define SYSCLK_DEFAULT_IOSC_HZ MHZ(120) @@ -40,8 +36,4 @@ extern "C" { #endif /* !_ASMLANGUAGE */ -#ifdef __cplusplus -} -#endif - #endif /* _SOC__H_ */ diff --git a/soc/arm/nxp_kinetis/kl2x/soc.h b/soc/arm/nxp_kinetis/kl2x/soc.h index f772368657e..de7fe614923 100644 --- a/soc/arm/nxp_kinetis/kl2x/soc.h +++ b/soc/arm/nxp_kinetis/kl2x/soc.h @@ -9,10 +9,6 @@ #include -#ifdef __cplusplus -extern "C" { -#endif - #define UART0_CLK_SRC kCLOCK_CoreSysClk #ifndef _ASMLANGUAGE @@ -24,8 +20,4 @@ extern "C" { #endif /* !_ASMLANGUAGE */ -#ifdef __cplusplus -} -#endif - #endif /* _SOC__H_ */ diff --git a/soc/arm/nxp_kinetis/kwx/soc.h b/soc/arm/nxp_kinetis/kwx/soc.h index 4181eb94a46..e9d3ca540a9 100644 --- a/soc/arm/nxp_kinetis/kwx/soc.h +++ b/soc/arm/nxp_kinetis/kwx/soc.h @@ -10,10 +10,6 @@ #include -#ifdef __cplusplus -extern "C" { -#endif - #if defined(CONFIG_SOC_MKW40Z4) || defined(CONFIG_SOC_MKW41Z4) #define LPUART0_CLK_SRC kCLOCK_CoreSysClk @@ -35,8 +31,4 @@ extern "C" { #endif /* !_ASMLANGUAGE */ -#ifdef __cplusplus -} -#endif - #endif /* _SOC__H_ */ diff --git a/soc/arm/nxp_lpc/lpc54xxx/soc.h b/soc/arm/nxp_lpc/lpc54xxx/soc.h index 7d5d626f406..19792488010 100644 --- a/soc/arm/nxp_lpc/lpc54xxx/soc.h +++ b/soc/arm/nxp_lpc/lpc54xxx/soc.h @@ -15,10 +15,6 @@ #ifndef _SOC__H_ #define _SOC__H_ -#ifdef __cplusplus -extern "C" { -#endif - #ifndef _ASMLANGUAGE #include #include @@ -36,8 +32,4 @@ extern "C" { #define IOCON_PIO_SLEW_STANDARD 0x00u #define IOCON_PIO_MODE_PULLUP 0x10u -#ifdef __cplusplus -} -#endif - #endif /* _SOC__H_ */ diff --git a/soc/arm/nxp_lpc/lpc55xxx/soc.h b/soc/arm/nxp_lpc/lpc55xxx/soc.h index 02bf6b08e15..d1fd4e40624 100644 --- a/soc/arm/nxp_lpc/lpc55xxx/soc.h +++ b/soc/arm/nxp_lpc/lpc55xxx/soc.h @@ -15,10 +15,6 @@ #ifndef _SOC__H_ #define _SOC__H_ -#ifdef __cplusplus -extern "C" { -#endif - #ifndef _ASMLANGUAGE #include #include @@ -37,8 +33,4 @@ extern "C" { #define IOCON_PIO_MODE_PULLUP 0x20u /*!<@brief Selects pull-up function */ #define IOCON_PIO_INPFILT_OFF 0x1000u /*!<@brief Input filter disabled */ -#ifdef __cplusplus -} -#endif - #endif /* _SOC__H_ */