Remove redundant extern declarations
Subsystems (16)
v2 cover Remove redundant extern declarations
This series removes unnecessary extern keywords from function declarations that use asmlinkage across various architectures and core subsystems.
In C, function declarations at file scope have external linkage by default, making the explicit extern keyword redundant. Additionally, asmlinkage already expands to extern "C" when __cplusplus is defined, so combining it with extern results in duplicate linkage specifiers.
Changes in v2:
- Fix commit messages corrupted by shell expansion in v1.
- Clarify the rationale based on C linkage rules and asmlinkage macro expansion rather than C++ module compilation.
- Format the Bugzilla URL using the standard Link: tag.
Safocl Stollmannovic (10):
ARM: fix duplicate extern declarations
loongarch: fix duplicate extern declarations
microblaze: fix duplicate extern declarations
MIPS: fix duplicate extern declarations
openrisc: fix duplicate extern declarations
riscv: fix duplicate extern declarations
x86: fix duplicate extern declarations
drivers: fix duplicate extern declarations sched/preempt: fix duplicate extern declarations
kernel: fix duplicate extern declarations
arch/arm/include/asm/bug.h | 2 +- arch/arm/include/asm/opcodes.h | 2 +- arch/loongarch/include/asm/idle.h | 2 +- arch/loongarch/include/asm/smp.h | 4 +- arch/loongarch/include/asm/switch_to.h | 2 +- arch/microblaze/include/asm/entry.h | 2 +- arch/microblaze/kernel/microblaze_ksyms.c | 2 +- arch/mips/cavium-octeon/setup.c | 2 +- arch/mips/include/asm/bmips.h | 2 +- arch/mips/include/asm/idle.h | 2 +- arch/mips/include/asm/paccess.h | 4 +- arch/mips/include/asm/ptrace.h | 4 +- arch/mips/include/asm/smp.h | 2 +- arch/mips/include/asm/switch_to.h | 2 +- arch/mips/kernel/r4k-bugs64.c | 2 +- arch/mips/kernel/signal-common.h | 8 ++-- arch/mips/kernel/traps.c | 50 +++++++++++------------ arch/openrisc/kernel/process.c | 2 +- arch/riscv/include/asm/string.h | 24 +++++------ arch/riscv/kernel/process.c | 4 +- arch/riscv/kernel/stacktrace.c | 2 +- arch/x86/include/asm/efi.h | 2 +- arch/x86/include/asm/gsseg.h | 2 +- arch/x86/include/asm/preempt.h | 8 ++-- arch/x86/include/asm/processor.h | 2 +- arch/x86/include/asm/suspend.h | 2 +- arch/x86/um/sys_call_table_32.c | 4 +- arch/x86/um/sys_call_table_64.c | 4 +- drivers/soc/bcm/brcmstb/pm/pm.h | 6 +-- include/asm-generic/preempt.h | 4 +- include/linux/lockdep.h | 2 +- include/linux/printk.h | 6 +-- include/linux/sched/task.h | 2 +- include/linux/start_kernel.h | 2 +- include/linux/suspend.h | 4 +- 35 files changed, 88 insertions(+), 88 deletions(-)
--
2.56.1
PATCH v2 1/10 ARM: fix duplicate extern declarations
Compiling a kernel module with a C++ compiler results in a "duplicate extern specifier" error.
This occurs because the code contains extern asmlinkage, and asmlinkage expands to extern C when processed by a C++ compiler.
Since the code already contains sections that respond to a C++ compiler, I believe it is a perfectly valid approach to gradually move toward a state where kernel modules can be compiled by a C++ compiler without any issues. The extern specifier must be removed.
--- arch/arm/include/asm/bug.h | 2 +- arch/arm/include/asm/opcodes.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
arch/arm/include/asm/bug.h +1 -1
@@ -82,7 +82,7 @@ void hook_ifault_code(int nr, int (*fn)(unsigned long, unsigned int, struct pt_regs *), int sig, int code, const char *name); -extern asmlinkage void c_backtrace(unsigned long fp, int pmode, +asmlinkage void c_backtrace(unsigned long fp, int pmode,const char *loglvl);struct mm_struct ;
arch/arm/include/asm/opcodes.h +1 -1
@@ -8,7 +8,7 @@#ifndef __ASSEMBLY__#include <linux/linkage.h> -extern asmlinkage unsigned int arm_check_condition(u32 opcode, u32 psr); +asmlinkage unsigned int arm_check_condition(u32 opcode, u32 psr);#endif #define ARM_OPCODE_CONDTEST_FAIL 0
Signature · 1 line
2.56.1
PATCH v2 2/10 loongarch: fix duplicate extern declarations
In reply to Safocl StollmannovicCompiling a kernel module with a C++ compiler results in a "duplicate extern specifier" error.
This occurs because the code contains extern asmlinkage, and asmlinkage expands to extern C when processed by a C++ compiler.
Since the code already contains sections that respond to a C++ compiler, I believe it is a perfectly valid approach to gradually move toward a state where kernel modules can be compiled by a C++ compiler without any issues. The extern specifier must be removed.
--- arch/loongarch/include/asm/idle.h | 2 +- arch/loongarch/include/asm/smp.h | 4 ++-- arch/loongarch/include/asm/switch_to.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-)
arch/loongarch/include/asm/idle.h +1 -1
@@ -4,6 +4,6 @@#include <linux/linkage.h> -extern asmlinkage void __arch_cpu_idle(void); +asmlinkage void __arch_cpu_idle(void);#endif /* __ASM_IDLE_H */
arch/loongarch/include/asm/smp.h +2 -2
@@ -87,8 +87,8 @@ struct secondary_data { };extern struct secondary_data cpuboot_data; -extern asmlinkage void smpboot_entry(void); -extern asmlinkage void start_secondary(void); +asmlinkage void smpboot_entry(void); +asmlinkage void start_secondary(void);extern void calculate_cpu_foreign_map (void );
arch/loongarch/include/asm/switch_to.h +1 -1
@@ -21,7 +21,7 @@ struct task_struct;* This function is used whilst scheduling to save the context of prev & load * the context of next. Returns prev. */ -extern asmlinkage struct task_struct *__switch_to(struct task_struct *prev, +asmlinkage struct task_struct *__switch_to(struct task_struct *prev,struct task_struct *next,void *sched_ra,void *sched_cfa);/*
Signature · 1 line
2.56.1
PATCH v2 3/10 microblaze: fix duplicate extern declarations
In reply to Safocl StollmannovicCompiling a kernel module with a C++ compiler results in a "duplicate extern specifier" error.
This occurs because the code contains extern asmlinkage, and asmlinkage expands to extern C when processed by a C++ compiler.
Since the code already contains sections that respond to a C++ compiler, I believe it is a perfectly valid approach to gradually move toward a state where kernel modules can be compiled by a C++ compiler without any issues. The extern specifier must be removed.
--- arch/microblaze/include/asm/entry.h | 2 +- arch/microblaze/kernel/microblaze_ksyms.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
arch/microblaze/include/asm/entry.h +1 -1
@@ -41,7 +41,7 @@ DECLARE_PER_CPU(unsigned int, ENTRY_SP); /* Saved SP on kernel entry */ DECLARE_PER_CPU(unsigned int, R11_SAVE); /* Temp variable for entry */ DECLARE_PER_CPU(unsigned int, CURRENT_SAVE); /* Saved current pointer */ -extern asmlinkage void do_notify_resume(struct pt_regs *regs, int in_syscall); +asmlinkage void do_notify_resume(struct pt_regs *regs, int in_syscall);# endif /* __ASSEMBLER__ */ #endif /* _ASM_MICROBLAZE_ENTRY_H */
arch/microblaze/kernel/microblaze_ksyms.c +1 -1
@@ -51,6 +51,6 @@ extern void xmb_manager_register(uintptr_t phys_baseaddr, u32 cr_val,void (*callback)(void *data), void *priv, void (*reset_callback)(void *data));EXPORT_SYMBOL (xmb_manager_register); -extern asmlinkage void xmb_inject_err(void); +asmlinkage void xmb_inject_err(void);EXPORT_SYMBOL (xmb_inject_err);#endif
Signature · 1 line
2.56.1
PATCH v2 4/10 MIPS: fix duplicate extern declarations
In reply to Safocl StollmannovicCompiling a kernel module with a C++ compiler results in a "duplicate extern specifier" error.
This occurs because the code contains extern asmlinkage, and asmlinkage expands to extern C when processed by a C++ compiler.
Since the code already contains sections that respond to a C++ compiler, I believe it is a perfectly valid approach to gradually move toward a state where kernel modules can be compiled by a C++ compiler without any issues. The extern specifier must be removed.
--- arch/mips/cavium-octeon/setup.c | 2 +- arch/mips/include/asm/bmips.h | 2 +- arch/mips/include/asm/idle.h | 2 +- arch/mips/include/asm/paccess.h | 4 +-- arch/mips/include/asm/ptrace.h | 4 +-- arch/mips/include/asm/smp.h | 2 +- arch/mips/include/asm/switch_to.h | 2 +- arch/mips/kernel/r4k-bugs64.c | 2 +- arch/mips/kernel/signal-common.h | 8 ++--- arch/mips/kernel/traps.c | 50 +++++++++++++++---------------- 10 files changed, 39 insertions(+), 39 deletions(-)
arch/mips/cavium-octeon/setup.c +1 -1
@@ -296,7 +296,7 @@ static uint64_t crashk_size, crashk_base;static int octeon_uart; -extern asmlinkage void handle_int(void); +asmlinkage void handle_int(void);/** * octeon_is_simulation - Return non-zero if we are currently running
arch/mips/include/asm/bmips.h +1 -1
@@ -88,7 +88,7 @@ extern cpumask_t bmips_booted_mask;extern unsigned long bmips_tp1_irqs;extern void bmips_ebase_setup (void ); -extern asmlinkage void plat_wired_tlb_setup(void); +asmlinkage void plat_wired_tlb_setup(void);extern void bmips_cpu_setup (void );static inline unsigned long bmips_read_zscm_reg (unsigned int offset)
arch/mips/include/asm/idle.h +1 -1
@@ -6,7 +6,7 @@#include <linux/linkage.h> extern void (*cpu_wait)(void ); -extern asmlinkage void r4k_wait(void); +asmlinkage void r4k_wait(void);extern void r4k_wait_irqoff (void );static inline int using_skipover_handler (void )
arch/mips/include/asm/paccess.h +2 -2
@@ -22,8 +22,8 @@#define __PA_ADDR ".dword"#endif -extern asmlinkage void handle_ibe(void); -extern asmlinkage void handle_dbe(void); +asmlinkage void handle_ibe(void); +asmlinkage void handle_dbe(void);#define put_dbe (x, ptr) __put_dbe((x), (ptr), sizeof(*(ptr)))#define get_dbe (x, ptr) __get_dbe((x), (ptr), sizeof(*(ptr)))
arch/mips/include/asm/ptrace.h +2 -2
@@ -160,8 +160,8 @@ extern unsigned long exception_ip(struct pt_regs *regs);#define exception_ip (regs) exception_ip(regs)#define profile_pc (regs) instruction_pointer(regs) -extern asmlinkage long syscall_trace_enter (struct pt_regs *regs); -extern asmlinkage void syscall_trace_leave(struct pt_regs *regs); +asmlinkage long syscall_trace_enter (struct pt_regs *regs); +asmlinkage void syscall_trace_leave(struct pt_regs *regs);extern void die (const char *,struct pt_regs *)__noreturn ;
arch/mips/include/asm/smp.h +1 -1
@@ -58,7 +58,7 @@ extern cpumask_t cpu_coherent_mask;extern unsigned int smp_max_threads__initdata ; -extern asmlinkage void smp_bootstrap(void); +asmlinkage void smp_bootstrap(void);extern void calculate_cpu_foreign_map (void );
arch/mips/include/asm/switch_to.h +1 -1
@@ -29,7 +29,7 @@ struct task_struct;* This function is used whilst scheduling to save the context of prev & load * the context of next. Returns prev. */ -extern asmlinkage struct task_struct *resume(struct task_struct *prev, +asmlinkage struct task_struct *resume(struct task_struct *prev,struct task_struct *next,struct thread_info *next_ti);extern unsigned int ll_bit;
arch/mips/kernel/r4k-bugs64.c +1 -1
@@ -182,7 +182,7 @@ asmlinkage void __init do_daddi_ov(struct pt_regs *regs)static __init void check_daddi (void ) { - extern asmlinkage void handle_daddi_ov(void); + asmlinkage void handle_daddi_ov(void);unsigned long flags;void *handler;long v, tmp;
arch/mips/kernel/signal-common.h +4 -4
@@ -32,13 +32,13 @@ extern int fpcsr_pending(unsigned int __user *fpcsr);#define unlock_fpu_owner () ({ pagefault_enable(); preempt_enable(); })/* Assembly functions to move context to/from the FPU */ -extern asmlinkage int +asmlinkage int_save_fp_context (void __user *fpregs,void __user *csr); -extern asmlinkage int +asmlinkage int_restore_fp_context (void __user *fpregs,void __user *csr); -extern asmlinkage int _save_msa_all_upper(void __user *buf); -extern asmlinkage int _restore_msa_all_upper(void __user *buf); +asmlinkage int _save_msa_all_upper(void __user *buf); +asmlinkage int _restore_msa_all_upper(void __user *buf);extern int setup_sigcontext (struct pt_regs *,struct sigcontext __user *);extern int restore_sigcontext (struct pt_regs *,struct sigcontext __user *);
arch/mips/kernel/traps.c +25 -25
56 lines not on this page · raw message
Signature · 1 line
2.56.1
PATCH v2 5/10 openrisc: fix duplicate extern declarations
In reply to Safocl StollmannovicCompiling a kernel module with a C++ compiler results in a "duplicate extern specifier" error.
This occurs because the code contains extern asmlinkage, and asmlinkage expands to extern C when processed by a C++ compiler.
Since the code already contains sections that respond to a C++ compiler, I believe it is a perfectly valid approach to gradually move toward a state where kernel modules can be compiled by a C++ compiler without any issues. The extern specifier must be removed.
--- arch/openrisc/kernel/process.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/openrisc/kernel/process.c +1 -1
@@ -129,7 +129,7 @@ void show_regs(struct pt_regs *regs)* Copy the thread-specific (arch specific) info from the current * process to the new one p */ -extern asmlinkage void ret_from_fork(void); +asmlinkage void ret_from_fork(void);/* * copy_thread
Signature · 1 line
2.56.1
PATCH v2 6/10 riscv: fix duplicate extern declarations
In reply to Safocl StollmannovicCompiling a kernel module with a C++ compiler results in a "duplicate extern specifier" error.
This occurs because the code contains extern asmlinkage, and asmlinkage expands to extern C when processed by a C++ compiler.
Since the code already contains sections that respond to a C++ compiler, I believe it is a perfectly valid approach to gradually move toward a state where kernel modules can be compiled by a C++ compiler without any issues. The extern specifier must be removed.
--- arch/riscv/include/asm/string.h | 24 ++++++++++++------------ arch/riscv/kernel/process.c | 4 ++-- arch/riscv/kernel/stacktrace.c | 2 +- 3 files changed, 15 insertions(+), 15 deletions(-)
arch/riscv/include/asm/string.h +12 -12
@@ -10,33 +10,33 @@#include <linux/linkage.h> #define __HAVE_ARCH_MEMSET -extern asmlinkage void *memset(void *, int, size_t); -extern asmlinkage void *__memset(void *, int, size_t); +asmlinkage void *memset(void *, int, size_t); +asmlinkage void *__memset(void *, int, size_t);#define __HAVE_ARCH_MEMCPY -extern asmlinkage void *memcpy(void *, const void *, size_t); -extern asmlinkage void *__memcpy(void *, const void *, size_t); +asmlinkage void *memcpy(void *, const void *, size_t); +asmlinkage void *__memcpy(void *, const void *, size_t);#define __HAVE_ARCH_MEMMOVE -extern asmlinkage void *memmove(void *, const void *, size_t); -extern asmlinkage void *__memmove(void *, const void *, size_t); +asmlinkage void *memmove(void *, const void *, size_t); +asmlinkage void *__memmove(void *, const void *, size_t);#if !(defined(CONFIG_KASAN_GENERIC ) || defined(CONFIG_KASAN_SW_TAGS ))#define __HAVE_ARCH_STRCMP -extern asmlinkage int strcmp(const char *cs, const char *ct); +asmlinkage int strcmp(const char *cs, const char *ct);#define __HAVE_ARCH_STRLEN -extern asmlinkage __kernel_size_t strlen(const char *); +asmlinkage __kernel_size_t strlen(const char *);#define __HAVE_ARCH_STRNCMP -extern asmlinkage int strncmp(const char *cs, const char *ct, size_t count); +asmlinkage int strncmp(const char *cs, const char *ct, size_t count);#define __HAVE_ARCH_STRNLEN -extern asmlinkage __kernel_size_t strnlen(const char *, size_t); +asmlinkage __kernel_size_t strnlen(const char *, size_t);#define __HAVE_ARCH_STRCHR -extern asmlinkage char *strchr(const char *, int); +asmlinkage char *strchr(const char *, int);#define __HAVE_ARCH_STRRCHR -extern asmlinkage char *strrchr(const char *, int); +asmlinkage char *strrchr(const char *, int);#endif /* For those files which don't want to check by kasan. */
arch/riscv/kernel/process.c +2 -2
@@ -39,8 +39,8 @@ unsigned long __stack_chk_guard __read_mostly;EXPORT_SYMBOL (__stack_chk_guard);#endif -extern asmlinkage void ret_from_fork_kernel_asm(void); -extern asmlinkage void ret_from_fork_user_asm(void); +asmlinkage void ret_from_fork_kernel_asm(void); +asmlinkage void ret_from_fork_user_asm(void); void noinstr arch_cpu_idle(void) {
arch/riscv/kernel/stacktrace.c +1 -1
@@ -32,7 +32,7 @@ val; \ }) -extern asmlinkage void handle_exception(void); +asmlinkage void handle_exception(void);extern unsigned long ret_from_exception_end;static inline int fp_is_valid (unsigned long fp,unsigned long sp)
Signature · 1 line
2.56.1
PATCH v2 7/10 x86: fix duplicate extern declarations
In reply to Safocl StollmannovicCompiling a kernel module with a C++ compiler results in a "duplicate extern specifier" error.
This occurs because the code contains extern asmlinkage, and asmlinkage expands to extern C when processed by a C++ compiler.
Since the code already contains sections that respond to a C++ compiler, I believe it is a perfectly valid approach to gradually move toward a state where kernel modules can be compiled by a C++ compiler without any issues. The extern specifier must be removed.
--- arch/x86/include/asm/efi.h | 2 +- arch/x86/include/asm/gsseg.h | 2 +- arch/x86/include/asm/preempt.h | 8 ++++---- arch/x86/include/asm/processor.h | 2 +- arch/x86/include/asm/suspend.h | 2 +- arch/x86/um/sys_call_table_32.c | 4 ++-- arch/x86/um/sys_call_table_64.c | 4 ++-- 7 files changed, 12 insertions(+), 12 deletions(-)
arch/x86/include/asm/efi.h +1 -1
@@ -94,7 +94,7 @@ static inline void efi_fpu_end(void)#else /* !CONFIG_X86_32 */ #define EFI_X86_KERNEL_ALLOC_LIMIT EFI_ALLOC_LIMIT -extern asmlinkage u64 __efi_call(void *fp, ...); +asmlinkage u64 __efi_call(void *fp, ...);extern bool efi_disable_ibt_for_runtime;
arch/x86/include/asm/gsseg.h +1 -1
@@ -12,7 +12,7 @@#ifdef CONFIG_X86_64 -extern asmlinkage void asm_load_gs_index(u16 selector); +asmlinkage void asm_load_gs_index(u16 selector);/* Replace with "lkgs %di" once binutils support LKGS instruction */ #define LKGS_DI _ASM_BYTES(0xf2,0x0f,0x00,0xf7)
arch/x86/include/asm/preempt.h +4 -4
@@ -134,11 +134,11 @@ static __always_inline bool should_resched(int preempt_offset)#ifdef CONFIG_PREEMPTION -extern asmlinkage void preempt_schedule(void); -extern asmlinkage void preempt_schedule_thunk(void); +asmlinkage void preempt_schedule(void); +asmlinkage void preempt_schedule_thunk(void); -extern asmlinkage void preempt_schedule_notrace(void); -extern asmlinkage void preempt_schedule_notrace_thunk(void); +asmlinkage void preempt_schedule_notrace(void); +asmlinkage void preempt_schedule_notrace_thunk(void);#define __preempt_schedule () \ asm volatile ("call preempt_schedule_thunk" : ASM_CALL_CONSTRAINT);
arch/x86/include/asm/processor.h +1 -1
@@ -455,7 +455,7 @@ static inline unsigned long cpu_kernelmode_gs_base(int cpu)#endif } -extern asmlinkage void entry_SYSCALL32_ignore(void); +asmlinkage void entry_SYSCALL32_ignore(void);/* Save actual FS/GS selectors and bases to current->thread */ void current_save_fsgs (void );
arch/x86/include/asm/suspend.h +1 -1
@@ -11,4 +11,4 @@ extern unsigned long temp_pgt __visible;extern unsigned long relocated_restore_code __visible;extern int relocate_restore_code (void );/* Defined in hibernate_asm_32/64.S */ -extern asmlinkage __visible int restore_image(void); +asmlinkage __visible int restore_image(void);
arch/x86/um/sys_call_table_32.c +2 -2
@@ -9,7 +9,7 @@#include <linux/cache.h> #include <asm/syscall.h> -extern asmlinkage long sys_ni_syscall (unsigned long ,unsigned long , +asmlinkage long sys_ni_syscall (unsigned long ,unsigned long ,unsigned long ,unsigned long ,unsigned long ,unsigned long );
@@ -28,7 +28,7 @@ extern asmlinkage long sys_ni_syscall(unsigned long, unsigned long,#define __SYSCALL_WITH_COMPAT (nr, native, compat) __SYSCALL(nr, native)#define __SYSCALL_NORETURN __SYSCALL -#define __SYSCALL (nr, sym) extern asmlinkage long sym(unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long); +#define __SYSCALL (nr, sym) asmlinkage long sym(unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long);#include <asm/syscalls_32.h> #undef __SYSCALL
arch/x86/um/sys_call_table_64.c +2 -2
@@ -9,7 +9,7 @@#include <linux/cache.h> #include <asm/syscall.h> -extern asmlinkage long sys_ni_syscall (unsigned long ,unsigned long , +asmlinkage long sys_ni_syscall (unsigned long ,unsigned long ,unsigned long ,unsigned long ,unsigned long ,unsigned long );
@@ -24,7 +24,7 @@ extern asmlinkage long sys_ni_syscall(unsigned long, unsigned long,#define __SYSCALL_NORETURN __SYSCALL -#define __SYSCALL (nr, sym) extern asmlinkage long sym(unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long); +#define __SYSCALL (nr, sym) asmlinkage long sym(unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long);#include <asm/syscalls_64.h> #undef __SYSCALL
Signature · 1 line
2.56.1
PATCH v2 8/10 drivers: fix duplicate extern declarations
In reply to Safocl StollmannovicCompiling a kernel module with a C++ compiler results in a "duplicate extern specifier" error.
This occurs because the code contains extern asmlinkage, and asmlinkage expands to extern C when processed by a C++ compiler.
Since the code already contains sections that respond to a C++ compiler, I believe it is a perfectly valid approach to gradually move toward a state where kernel modules can be compiled by a C++ compiler without any issues. The extern specifier must be removed.
--- drivers/soc/bcm/brcmstb/pm/pm.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/soc/bcm/brcmstb/pm/pm.h +3 -3
@@ -64,14 +64,14 @@#ifndef CONFIG_MIPS extern const unsigned long brcmstb_pm_do_s2_sz; -extern asmlinkage int brcmstb_pm_do_s2(void __iomem *aon_ctrl_base, +asmlinkage int brcmstb_pm_do_s2(void __iomem *aon_ctrl_base,void __iomem *ddr_phy_pll_status);#else /* s2 asm */ -extern asmlinkage int brcm_pm_do_s2(u32 *s2_params); +asmlinkage int brcm_pm_do_s2(u32 *s2_params);/* s3 asm */ -extern asmlinkage int brcm_pm_do_s3(void __iomem *aon_ctrl_base, +asmlinkage int brcm_pm_do_s3(void __iomem *aon_ctrl_base,int dcache_linesz);extern int s3_reentry;#endif /* CONFIG_MIPS */
Signature · 1 line
2.56.1
PATCH v2 9/10 sched/preempt: fix duplicate extern declarations
In reply to Safocl StollmannovicCompiling a kernel module with a C++ compiler results in a "duplicate extern specifier" error.
This occurs because the code contains extern asmlinkage, and asmlinkage expands to extern C when processed by a C++ compiler.
Since the code already contains sections that respond to a C++ compiler, I believe it is a perfectly valid approach to gradually move toward a state where kernel modules can be compiled by a C++ compiler without any issues. The extern specifier must be removed.
--- include/asm-generic/preempt.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
include/asm-generic/preempt.h +2 -2
@@ -93,8 +93,8 @@ static __always_inline bool should_resched(int preempt_offset) }#ifdef CONFIG_PREEMPTION -extern asmlinkage void preempt_schedule(void); -extern asmlinkage void preempt_schedule_notrace(void); +asmlinkage void preempt_schedule(void); +asmlinkage void preempt_schedule_notrace(void);#define __preempt_schedule () preempt_schedule()#define __preempt_schedule_notrace () preempt_schedule_notrace()
Signature · 1 line
2.56.1
PATCH v2 10/10 kernel: fix duplicate extern declarations
In reply to Safocl StollmannovicCompiling a kernel module with a C++ compiler results in a "duplicate extern specifier" error.
This occurs because the code contains extern asmlinkage, and asmlinkage expands to extern C when processed by a C++ compiler.
Since the code already contains sections that respond to a C++ compiler, I believe it is a perfectly valid approach to gradually move toward a state where kernel modules can be compiled by a C++ compiler without any issues. The extern specifier must be removed.
--- include/linux/lockdep.h | 2 +- include/linux/printk.h | 6 +++--- include/linux/sched/task.h | 2 +- include/linux/start_kernel.h | 2 +- include/linux/suspend.h | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-)
include/linux/lockdep.h +1 -1
@@ -89,7 +89,7 @@ extern void lockdep_init(void);extern void lockdep_reset (void );extern void lockdep_reset_lock (struct lockdep_map *lock);extern void lockdep_free_key_range (void *start,unsigned long size); -extern asmlinkage void lockdep_sys_exit(void); +asmlinkage void lockdep_sys_exit(void);extern void lockdep_set_selftest_task (struct task_struct *task);extern void lockdep_init_task (struct task_struct *task);
include/linux/printk.h +3 -3
@@ -136,7 +136,7 @@ struct va_format { })#ifdef CONFIG_EARLY_PRINTK -extern asmlinkage __printf(1, 2) +asmlinkage __printf(1, 2) void early_printk(const char *fmt, ...); #else static inline __printf(1, 2) __cold
@@ -200,8 +200,8 @@ void __init setup_log_buf(int early); __printf(1, 2) void dump_stack_set_arch_desc(const char *fmt, ...);void dump_stack_print_info (const char *log_lvl);void show_regs_print_info (const char *log_lvl); -extern asmlinkage void dump_stack_lvl(const char *log_lvl) __cold; -extern asmlinkage void dump_stack(void) __cold; +asmlinkage void dump_stack_lvl(const char *log_lvl) __cold; +asmlinkage void dump_stack(void) __cold;void printk_trigger_flush (void );void console_try_replay_all (void );void printk_legacy_allow_panic_sync (void );
include/linux/sched/task.h +1 -1
@@ -61,7 +61,7 @@ extern struct task_struct init_task;extern int lockdep_tasklist_lock_is_held (void ); -extern asmlinkage void schedule_tail(struct task_struct *prev); +asmlinkage void schedule_tail(struct task_struct *prev);extern void init_idle (struct task_struct *idle,int cpu);extern int sched_fork (u64 clone_flags,struct task_struct *p);
include/linux/start_kernel.h +1 -1
@@ -8,6 +8,6 @@/* Define the prototype for start_kernel here, rather than cluttering up something else. */ -extern asmlinkage void __init __noreturn start_kernel(void); +asmlinkage void __init __noreturn start_kernel(void);#endif /* _LINUX_START_KERNEL_H */
include/linux/suspend.h +2 -2
@@ -385,8 +385,8 @@ extern int swsusp_page_is_forbidden(struct page *);extern void swsusp_set_page_free (struct page *);extern void swsusp_unset_page_free (struct page *);extern unsigned long get_safe_page (gfp_t gfp_mask); -extern asmlinkage int swsusp_arch_suspend(void); -extern asmlinkage int swsusp_arch_resume(void); +asmlinkage int swsusp_arch_suspend(void); +asmlinkage int swsusp_arch_resume(void);extern u32 swsusp_hardware_signature;extern void hibernation_set_ops (const struct platform_hibernation_ops *ops);
Signature · 1 line
2.56.1
Re: [PATCH v2 10/10] kernel: fix duplicate extern declarations
Quoted 8 lines · Safocl Stollmannovic
Compiling a kernel module with a C++ compiler results in a "duplicate extern specifier" error.
This occurs because the code containsextern asmlinkage, andasmlinkageexpands toextern Cwhen processed by a C++ compiler.
Since the code already contains sections that respond to a C++ compiler, I believe it is a perfectly valid approach to gradually move toward a state where kernel modules can be compiled by a C++ compiler without any issues. Theexternspecifier must be removed.
Do you have any use case in mind?
Quoted 3 lines
No blank line in a tag block.
Quoted 7 lines
Signed-off-by Safocl Stollmannovic <[email protected]>--- include/linux/lockdep.h | 2 +- include/linux/printk.h | 6 +++--- include/linux/sched/task.h | 2 +- include/linux/start_kernel.h | 2 +- include/linux/suspend.h | 4 ++--
This should be 5 patches I think.
Signature · 2 lines
With Best Regards, Andy Shevchenko