1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 21:47:46 +00:00

Kernel: Tell compiler about invisible calls

This makes the Kernel build cleanly with -Wmissing-declarations.
This commit is contained in:
Ben Wiederhake 2020-08-11 23:33:37 +02:00 committed by Andreas Kling
parent 8a41ce5cc7
commit 936d5dcc01
3 changed files with 47 additions and 28 deletions

View file

@ -29,8 +29,9 @@
#include <AK/StringBuilder.h>
#include <AK/Types.h>
#include <Kernel/Arch/i386/CPU.h>
#include <Kernel/Arch/i386/ProcessorInfo.h>
#include <Kernel/Arch/i386/ISRStubs.h>
#include <Kernel/Arch/i386/ProcessorInfo.h>
#include <Kernel/IO.h>
#include <Kernel/Interrupts/APIC.h>
#include <Kernel/Interrupts/GenericInterruptHandler.h>
#include <Kernel/Interrupts/IRQHandler.h>
@ -44,7 +45,6 @@
#include <Kernel/Thread.h>
#include <Kernel/VM/MemoryManager.h>
#include <Kernel/VM/PageDirectory.h>
#include <Kernel/IO.h>
#include <LibC/mallocdefs.h>
//#define PAGE_FAULT_DEBUG
@ -58,6 +58,13 @@ static Descriptor s_idt[256];
static GenericInterruptHandler* s_interrupt_handler[GENERIC_INTERRUPT_HANDLERS_COUNT];
// The compiler can't see the calls to these functions inside assembly.
// Declare them, to avoid dead code warnings.
extern "C" void enter_thread_context(Thread* from_thread, Thread* to_thread);
extern "C" void context_first_init(Thread* from_thread, Thread* to_thread, TrapFrame* trap);
extern "C" u32 do_init_context(Thread* thread, u32 flags);
extern "C" void pre_init_finished(void);
extern "C" void post_init_finished(void);
extern "C" void handle_interrupt(TrapFrame*);
#define EH_ENTRY(ec, title) \
@ -1300,7 +1307,6 @@ u32 Processor::init_context(Thread& thread, bool leave_crit)
return stack_top;
}
extern "C" u32 do_init_context(Thread* thread, u32 flags)
{
ASSERT_INTERRUPTS_DISABLED();

View file

@ -282,11 +282,6 @@ char* strstr(const char* haystack, const char* needle)
return const_cast<char*>(haystack);
}
[[noreturn]] void __cxa_pure_virtual()
{
ASSERT_NOT_REACHED();
}
void* realloc(void* p, size_t s)
{
return krealloc(p, s);
@ -297,6 +292,13 @@ void free(void* p)
return kfree(p);
}
// Functions that are automatically called by the C++ compiler.
// Declare them first, to tell the silly compiler that they are indeed being used.
[[noreturn]] void __stack_chk_fail();
[[noreturn]] void __stack_chk_fail_local();
extern "C" int __cxa_atexit(void (*)(void*), void*, void*);
[[noreturn]] void __cxa_pure_virtual();
[[noreturn]] void __stack_chk_fail()
{
ASSERT_NOT_REACHED();
@ -312,4 +314,9 @@ extern "C" int __cxa_atexit(void (*)(void*), void*, void*)
ASSERT_NOT_REACHED();
return 0;
}
[[noreturn]] void __cxa_pure_virtual()
{
ASSERT_NOT_REACHED();
}
}

View file

@ -89,6 +89,12 @@ namespace Kernel {
[[noreturn]] static void init_stage2();
static void setup_serial_debug();
// boot.S expects these functions precisely this this. We declare them here
// to ensure the signatures don't accidentally change.
extern "C" void init_finished(u32 cpu);
extern "C" [[noreturn]] void init_ap(u32 cpu, Processor* processor_info);
extern "C" [[noreturn]] void init();
VirtualConsole* tty0;
static Processor s_bsp_processor; // global but let's keep it "private"