arch/xtensa: 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:
parent
c315475bb0
commit
817f527641
5 changed files with 28 additions and 32 deletions
|
@ -20,15 +20,15 @@
|
||||||
#ifndef ZEPHYR_ARCH_XTENSA_INCLUDE_KERNEL_ARCH_DATA_H_
|
#ifndef ZEPHYR_ARCH_XTENSA_INCLUDE_KERNEL_ARCH_DATA_H_
|
||||||
#define ZEPHYR_ARCH_XTENSA_INCLUDE_KERNEL_ARCH_DATA_H_
|
#define ZEPHYR_ARCH_XTENSA_INCLUDE_KERNEL_ARCH_DATA_H_
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <toolchain.h>
|
#include <toolchain.h>
|
||||||
#include <linker/sections.h>
|
#include <linker/sections.h>
|
||||||
#include <arch/cpu.h>
|
#include <arch/cpu.h>
|
||||||
#include <kernel_arch_thread.h>
|
#include <kernel_arch_thread.h>
|
||||||
|
|
||||||
|
/* stacks */
|
||||||
|
#define STACK_ROUND_UP(x) ROUND_UP(x, STACK_ALIGN_SIZE)
|
||||||
|
#define STACK_ROUND_DOWN(x) ROUND_DOWN(x, STACK_ALIGN_SIZE)
|
||||||
|
|
||||||
#if !defined(_ASMLANGUAGE) && !defined(__ASSEMBLER__)
|
#if !defined(_ASMLANGUAGE) && !defined(__ASSEMBLER__)
|
||||||
#include <kernel.h> /* public kernel API */
|
#include <kernel.h> /* public kernel API */
|
||||||
#include <kernel_internal.h>
|
#include <kernel_internal.h>
|
||||||
|
@ -36,6 +36,10 @@ extern "C" {
|
||||||
#include <sys/dlist.h>
|
#include <sys/dlist.h>
|
||||||
#include <sys/util.h>
|
#include <sys/util.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Bitmask definitions for the struct k_thread->flags bit field */
|
/* Bitmask definitions for the struct k_thread->flags bit field */
|
||||||
|
|
||||||
/* executing context is interrupt handler */
|
/* executing context is interrupt handler */
|
||||||
|
@ -47,20 +51,15 @@ extern "C" {
|
||||||
|
|
||||||
typedef struct __esf __esf_t;
|
typedef struct __esf __esf_t;
|
||||||
|
|
||||||
#endif /*! _ASMLANGUAGE && ! __ASSEMBLER__ */
|
|
||||||
|
|
||||||
#ifdef CONFIG_USE_SWITCH
|
#ifdef CONFIG_USE_SWITCH
|
||||||
void xtensa_switch(void *switch_to, void **switched_from);
|
void xtensa_switch(void *switch_to, void **switched_from);
|
||||||
#define z_arch_switch xtensa_switch
|
#define z_arch_switch xtensa_switch
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* stacks */
|
|
||||||
#define STACK_ROUND_UP(x) ROUND_UP(x, STACK_ALIGN_SIZE)
|
|
||||||
#define STACK_ROUND_DOWN(x) ROUND_DOWN(x, STACK_ALIGN_SIZE)
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* ZEPHYR_ARCH_XTENSA_INCLUDE_KERNEL_ARCH_DATA_H_ */
|
#endif /*! _ASMLANGUAGE && ! __ASSEMBLER__ */
|
||||||
|
|
||||||
|
#endif /* ZEPHYR_ARCH_XTENSA_INCLUDE_KERNEL_ARCH_DATA_H_ */
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
#ifndef _ASMLANGUAGE
|
#ifndef _ASMLANGUAGE
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
#include <stddef.h> /* For size_t */
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -119,8 +120,6 @@ z_set_thread_return_value(struct k_thread *thread, unsigned int value)
|
||||||
|
|
||||||
extern void k_cpu_atomic_idle(unsigned int key);
|
extern void k_cpu_atomic_idle(unsigned int key);
|
||||||
|
|
||||||
#include <stddef.h> /* For size_t */
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -6,10 +6,6 @@
|
||||||
#ifndef ZEPHYR_ARCH_XTENSA_INCLUDE_XTENSA_CONFIG_H_
|
#ifndef ZEPHYR_ARCH_XTENSA_INCLUDE_XTENSA_CONFIG_H_
|
||||||
#define ZEPHYR_ARCH_XTENSA_INCLUDE_XTENSA_CONFIG_H_
|
#define ZEPHYR_ARCH_XTENSA_INCLUDE_XTENSA_CONFIG_H_
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <xtensa/hal.h>
|
#include <xtensa/hal.h>
|
||||||
#include <xtensa/config/core.h>
|
#include <xtensa/config/core.h>
|
||||||
#include <xtensa/config/system.h> /* required for XSHAL_CLIB */
|
#include <xtensa/config/system.h> /* required for XSHAL_CLIB */
|
||||||
|
@ -133,9 +129,4 @@ extern "C" {
|
||||||
#define XT_STACK_EXTRA_CLIB (XT_XTRA_SIZE + XT_CLIB_CONTEXT_AREA_SIZE)
|
#define XT_STACK_EXTRA_CLIB (XT_XTRA_SIZE + XT_CLIB_CONTEXT_AREA_SIZE)
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* ZEPHYR_ARCH_XTENSA_INCLUDE_XTENSA_CONFIG_H_ */
|
#endif /* ZEPHYR_ARCH_XTENSA_INCLUDE_XTENSA_CONFIG_H_ */
|
||||||
|
|
||||||
|
|
|
@ -19,15 +19,18 @@
|
||||||
#ifndef ZEPHYR_ARCH_XTENSA_INCLUDE_XTENSA_CONTEXT_H_
|
#ifndef ZEPHYR_ARCH_XTENSA_INCLUDE_XTENSA_CONTEXT_H_
|
||||||
#define ZEPHYR_ARCH_XTENSA_INCLUDE_XTENSA_CONTEXT_H_
|
#define ZEPHYR_ARCH_XTENSA_INCLUDE_XTENSA_CONTEXT_H_
|
||||||
|
|
||||||
#ifdef __ASSEMBLER__
|
|
||||||
#include <xtensa/coreasm.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <xtensa/config/tie.h>
|
#include <xtensa/config/tie.h>
|
||||||
#include <xtensa/corebits.h>
|
#include <xtensa/corebits.h>
|
||||||
#include <xtensa/config/system.h>
|
#include <xtensa/config/system.h>
|
||||||
#include <xtensa/xtruntime-frames.h>
|
#include <xtensa/xtruntime-frames.h>
|
||||||
|
|
||||||
|
#ifdef __ASSEMBLER__
|
||||||
|
#include <xtensa/coreasm.h>
|
||||||
|
#else /* __ASSEMBLER__ */
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
#endif /* __ASSEMBLER__ */
|
||||||
|
|
||||||
/* Align a value up to nearest n-byte boundary, where n is a power of 2. */
|
/* Align a value up to nearest n-byte boundary, where n is a power of 2. */
|
||||||
#define ALIGNUP(n, val) (((val) + (n)-1) & -(n))
|
#define ALIGNUP(n, val) (((val) + (n)-1) & -(n))
|
||||||
|
@ -310,8 +313,11 @@ ret
|
||||||
#define RET(sz) retw
|
#define RET(sz) retw
|
||||||
#define RET0 retw
|
#define RET0 retw
|
||||||
#endif /* __XTENSA_CALL0_ABI__ */
|
#endif /* __XTENSA_CALL0_ABI__ */
|
||||||
|
#else /* __ASSEMBLER__ */
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
#endif /* __ASSEMBLER__ */
|
#endif /* __ASSEMBLER__ */
|
||||||
|
|
||||||
|
|
||||||
#endif /* ZEPHYR_ARCH_XTENSA_INCLUDE_XTENSA_CONTEXT_H_ */
|
#endif /* ZEPHYR_ARCH_XTENSA_INCLUDE_XTENSA_CONTEXT_H_ */
|
||||||
|
|
||||||
|
|
|
@ -15,10 +15,6 @@
|
||||||
|
|
||||||
#include <irq.h>
|
#include <irq.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <generated_dts_board.h>
|
#include <generated_dts_board.h>
|
||||||
#if !defined(_ASMLANGUAGE) && !defined(__ASSEMBLER__)
|
#if !defined(_ASMLANGUAGE) && !defined(__ASSEMBLER__)
|
||||||
#include <arch/common/sys_io.h>
|
#include <arch/common/sys_io.h>
|
||||||
|
@ -36,6 +32,10 @@ extern "C" {
|
||||||
|
|
||||||
#include <arch/xtensa/exc.h>
|
#include <arch/xtensa/exc.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
/* internal routine documented in C file, needed by IRQ_CONNECT() macro */
|
/* internal routine documented in C file, needed by IRQ_CONNECT() macro */
|
||||||
extern void z_irq_priority_set(u32_t irq, u32_t prio, u32_t flags);
|
extern void z_irq_priority_set(u32_t irq, u32_t prio, u32_t flags);
|
||||||
|
|
||||||
|
@ -95,9 +95,10 @@ static ALWAYS_INLINE void arch_nop(void)
|
||||||
__asm__ volatile("nop");
|
__asm__ volatile("nop");
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* !defined(_ASMLANGUAGE) && !defined(__ASSEMBLER__) */
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif /* !defined(_ASMLANGUAGE) && !defined(__ASSEMBLER__) */
|
||||||
|
|
||||||
#endif /* ZEPHYR_INCLUDE_ARCH_XTENSA_ARCH_H_ */
|
#endif /* ZEPHYR_INCLUDE_ARCH_XTENSA_ARCH_H_ */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue