arch/x86: 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.

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 <peter.bigot@nordicsemi.no>
This commit is contained in:
Peter Bigot 2019-08-12 15:54:24 -05:00 committed by Ioannis Glaropoulos
commit 324203f79b
2 changed files with 12 additions and 15 deletions

View file

@ -12,6 +12,8 @@
#ifndef _ASMLANGUAGE #ifndef _ASMLANGUAGE
#include <stddef.h> /* For size_t */
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
@ -92,8 +94,6 @@ static inline struct x86_mmu_pdpt *z_x86_pdpt_get(struct k_thread *thread)
/* ASM code to fiddle with registers to enable the MMU with PAE paging */ /* ASM code to fiddle with registers to enable the MMU with PAE paging */
void z_x86_enable_paging(void); void z_x86_enable_paging(void);
#include <stddef.h> /* For size_t */
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View file

@ -25,13 +25,12 @@
#include <misc/util.h> #include <misc/util.h>
#ifndef _ASMLANGUAGE #ifndef _ASMLANGUAGE
#include <stddef.h> /* for size_t */
#include <arch/common/addr_types.h> #include <arch/common/addr_types.h>
#include <arch/x86/ia32/segmentation.h> #include <arch/x86/ia32/segmentation.h>
#endif
#ifdef __cplusplus #endif /* _ASMLANGUAGE */
extern "C" {
#endif
/* GDT layout */ /* GDT layout */
#define CODE_SEG 0x08 #define CODE_SEG 0x08
@ -53,9 +52,13 @@ extern "C" {
#ifndef _ASMLANGUAGE #ifndef _ASMLANGUAGE
/* interrupt/exception/error related definitions */ #ifdef __cplusplus
extern "C" {
#endif
/* interrupt/exception/error related definitions */
/* /*
* The TCS must be aligned to the same boundary as that used by the floating * The TCS must be aligned to the same boundary as that used by the floating
* point register set. This applies even for threads that don't initially * point register set. This applies even for threads that don't initially
@ -315,10 +318,6 @@ struct _x86_syscall_stack_frame {
u32_t ss; u32_t ss;
}; };
#endif /* !_ASMLANGUAGE */
#ifndef _ASMLANGUAGE
/** /**
* *
* @internal * @internal
@ -561,8 +560,6 @@ extern void k_float_enable(struct k_thread *thread, unsigned int options);
* @} * @}
*/ */
#include <stddef.h> /* for size_t */
extern void k_cpu_idle(void); extern void k_cpu_idle(void);
extern u32_t z_timer_cycle_get_32(void); extern u32_t z_timer_cycle_get_32(void);
@ -809,10 +806,10 @@ int z_x86_mmu_validate(struct x86_mmu_pdpt *pdpt, void *addr, size_t size,
int write); int write);
#endif /* CONFIG_X86_MMU */ #endif /* CONFIG_X86_MMU */
#endif /* !_ASMLANGUAGE */
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif /* !_ASMLANGUAGE */
#endif /* ZEPHYR_INCLUDE_ARCH_X86_IA32_ARCH_H_ */ #endif /* ZEPHYR_INCLUDE_ARCH_X86_IA32_ARCH_H_ */