mirror of
https://github.com/SerenityOS/serenity
synced 2024-09-06 17:06:31 +00:00
Kernel: Mark compilation-unit-only functions as static
This enables a nice warning in case a function becomes dead code. Also, in case of signal_trampoline_dummy, marking it external (non-static) prevents it from being 'optimized away', which would lead to surprising and weird linker errors. I found these places by using -Wmissing-declarations. The Kernel still shows these issues, which I think are false-positives, but don't want to touch: - Kernel/Arch/i386/CPU.cpp:1081:17: void Kernel::enter_thread_context(Kernel::Thread*, Kernel::Thread*) - Kernel/Arch/i386/CPU.cpp:1170:17: void Kernel::context_first_init(Kernel::Thread*, Kernel::Thread*, Kernel::TrapFrame*) - Kernel/Arch/i386/CPU.cpp:1304:16: u32 Kernel::do_init_context(Kernel::Thread*, u32) - Kernel/Arch/i386/CPU.cpp:1347:17: void Kernel::pre_init_finished() - Kernel/Arch/i386/CPU.cpp:1360:17: void Kernel::post_init_finished() No idea, not gonna touch it. - Kernel/init.cpp:104:30: void Kernel::init() - Kernel/init.cpp:167:30: void Kernel::init_ap(u32, Kernel::Processor*) - Kernel/init.cpp:184:17: void Kernel::init_finished(u32) Called by boot.S. - Kernel/init.cpp:383:16: int Kernel::__cxa_atexit(void (*)(void*), void*, void*) - Kernel/StdLib.cpp:285:19: void __cxa_pure_virtual() - Kernel/StdLib.cpp:300:19: void __stack_chk_fail() - Kernel/StdLib.cpp:305:19: void __stack_chk_fail_local() Not sure how to tell the compiler that the compiler is already using them. Also, maybe __cxa_atexit should go into StdLib.cpp? - Kernel/Modules/TestModule.cpp:31:17: void module_init() - Kernel/Modules/TestModule.cpp:40:17: void module_fini() Could maybe go into a new header. This would also provide type-checking for new modules.
This commit is contained in:
parent
b1e8807bc5
commit
42b057b0c9
|
@ -37,7 +37,7 @@
|
|||
|
||||
namespace Kernel {
|
||||
|
||||
Lockable<HashTable<FIFO*>>& all_fifos()
|
||||
static Lockable<HashTable<FIFO*>>& all_fifos()
|
||||
{
|
||||
static Lockable<HashTable<FIFO*>>* s_table;
|
||||
if (!s_table)
|
||||
|
|
|
@ -39,7 +39,7 @@ namespace Kernel {
|
|||
|
||||
static SpinLock s_all_inodes_lock;
|
||||
|
||||
InlineLinkedList<Inode>& all_inodes()
|
||||
static InlineLinkedList<Inode>& all_inodes()
|
||||
{
|
||||
ASSERT(s_all_inodes_lock.is_locked());
|
||||
|
||||
|
|
|
@ -260,7 +260,7 @@ ProcFS::~ProcFS()
|
|||
{
|
||||
}
|
||||
|
||||
Optional<KBuffer> procfs$pid_fds(InodeIdentifier identifier)
|
||||
static Optional<KBuffer> procfs$pid_fds(InodeIdentifier identifier)
|
||||
{
|
||||
KBufferBuilder builder;
|
||||
JsonArraySerializer array { builder };
|
||||
|
@ -296,7 +296,7 @@ Optional<KBuffer> procfs$pid_fds(InodeIdentifier identifier)
|
|||
return builder.build();
|
||||
}
|
||||
|
||||
Optional<KBuffer> procfs$pid_fd_entry(InodeIdentifier identifier)
|
||||
static Optional<KBuffer> procfs$pid_fd_entry(InodeIdentifier identifier)
|
||||
{
|
||||
auto process = Process::from_pid(to_pid(identifier));
|
||||
if (!process)
|
||||
|
@ -308,7 +308,7 @@ Optional<KBuffer> procfs$pid_fd_entry(InodeIdentifier identifier)
|
|||
return description->absolute_path().to_byte_buffer();
|
||||
}
|
||||
|
||||
Optional<KBuffer> procfs$pid_vm(InodeIdentifier identifier)
|
||||
static Optional<KBuffer> procfs$pid_vm(InodeIdentifier identifier)
|
||||
{
|
||||
auto process = Process::from_pid(to_pid(identifier));
|
||||
if (!process)
|
||||
|
@ -357,7 +357,7 @@ Optional<KBuffer> procfs$pid_vm(InodeIdentifier identifier)
|
|||
return builder.build();
|
||||
}
|
||||
|
||||
Optional<KBuffer> procfs$pci(InodeIdentifier)
|
||||
static Optional<KBuffer> procfs$pci(InodeIdentifier)
|
||||
{
|
||||
KBufferBuilder builder;
|
||||
JsonArraySerializer array { builder };
|
||||
|
@ -379,7 +379,7 @@ Optional<KBuffer> procfs$pci(InodeIdentifier)
|
|||
return builder.build();
|
||||
}
|
||||
|
||||
Optional<KBuffer> procfs$interrupts(InodeIdentifier)
|
||||
static Optional<KBuffer> procfs$interrupts(InodeIdentifier)
|
||||
{
|
||||
KBufferBuilder builder;
|
||||
JsonArraySerializer array { builder };
|
||||
|
@ -396,7 +396,7 @@ Optional<KBuffer> procfs$interrupts(InodeIdentifier)
|
|||
return builder.build();
|
||||
}
|
||||
|
||||
Optional<KBuffer> procfs$keymap(InodeIdentifier)
|
||||
static Optional<KBuffer> procfs$keymap(InodeIdentifier)
|
||||
{
|
||||
KBufferBuilder builder;
|
||||
JsonObjectSerializer<KBufferBuilder> json { builder };
|
||||
|
@ -405,7 +405,7 @@ Optional<KBuffer> procfs$keymap(InodeIdentifier)
|
|||
return builder.build();
|
||||
}
|
||||
|
||||
Optional<KBuffer> procfs$devices(InodeIdentifier)
|
||||
static Optional<KBuffer> procfs$devices(InodeIdentifier)
|
||||
{
|
||||
KBufferBuilder builder;
|
||||
JsonArraySerializer array { builder };
|
||||
|
@ -426,14 +426,14 @@ Optional<KBuffer> procfs$devices(InodeIdentifier)
|
|||
return builder.build();
|
||||
}
|
||||
|
||||
Optional<KBuffer> procfs$uptime(InodeIdentifier)
|
||||
static Optional<KBuffer> procfs$uptime(InodeIdentifier)
|
||||
{
|
||||
KBufferBuilder builder;
|
||||
builder.appendf("%u\n", (g_uptime / 1000));
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
Optional<KBuffer> procfs$cmdline(InodeIdentifier)
|
||||
static Optional<KBuffer> procfs$cmdline(InodeIdentifier)
|
||||
{
|
||||
KBufferBuilder builder;
|
||||
builder.append(kernel_command_line().string());
|
||||
|
@ -441,7 +441,7 @@ Optional<KBuffer> procfs$cmdline(InodeIdentifier)
|
|||
return builder.build();
|
||||
}
|
||||
|
||||
Optional<KBuffer> procfs$modules(InodeIdentifier)
|
||||
static Optional<KBuffer> procfs$modules(InodeIdentifier)
|
||||
{
|
||||
extern HashMap<String, OwnPtr<Module>>* g_modules;
|
||||
KBufferBuilder builder;
|
||||
|
@ -461,7 +461,7 @@ Optional<KBuffer> procfs$modules(InodeIdentifier)
|
|||
return builder.build();
|
||||
}
|
||||
|
||||
Optional<KBuffer> procfs$profile(InodeIdentifier)
|
||||
static Optional<KBuffer> procfs$profile(InodeIdentifier)
|
||||
{
|
||||
InterruptDisabler disabler;
|
||||
KBufferBuilder builder;
|
||||
|
@ -493,7 +493,7 @@ Optional<KBuffer> procfs$profile(InodeIdentifier)
|
|||
return builder.build();
|
||||
}
|
||||
|
||||
Optional<KBuffer> procfs$net_adapters(InodeIdentifier)
|
||||
static Optional<KBuffer> procfs$net_adapters(InodeIdentifier)
|
||||
{
|
||||
KBufferBuilder builder;
|
||||
JsonArraySerializer array { builder };
|
||||
|
@ -519,7 +519,7 @@ Optional<KBuffer> procfs$net_adapters(InodeIdentifier)
|
|||
return builder.build();
|
||||
}
|
||||
|
||||
Optional<KBuffer> procfs$net_arp(InodeIdentifier)
|
||||
static Optional<KBuffer> procfs$net_arp(InodeIdentifier)
|
||||
{
|
||||
KBufferBuilder builder;
|
||||
JsonArraySerializer array { builder };
|
||||
|
@ -533,7 +533,7 @@ Optional<KBuffer> procfs$net_arp(InodeIdentifier)
|
|||
return builder.build();
|
||||
}
|
||||
|
||||
Optional<KBuffer> procfs$net_tcp(InodeIdentifier)
|
||||
static Optional<KBuffer> procfs$net_tcp(InodeIdentifier)
|
||||
{
|
||||
KBufferBuilder builder;
|
||||
JsonArraySerializer array { builder };
|
||||
|
@ -555,7 +555,7 @@ Optional<KBuffer> procfs$net_tcp(InodeIdentifier)
|
|||
return builder.build();
|
||||
}
|
||||
|
||||
Optional<KBuffer> procfs$net_udp(InodeIdentifier)
|
||||
static Optional<KBuffer> procfs$net_udp(InodeIdentifier)
|
||||
{
|
||||
KBufferBuilder builder;
|
||||
JsonArraySerializer array { builder };
|
||||
|
@ -570,7 +570,7 @@ Optional<KBuffer> procfs$net_udp(InodeIdentifier)
|
|||
return builder.build();
|
||||
}
|
||||
|
||||
Optional<KBuffer> procfs$net_local(InodeIdentifier)
|
||||
static Optional<KBuffer> procfs$net_local(InodeIdentifier)
|
||||
{
|
||||
KBufferBuilder builder;
|
||||
JsonArraySerializer array { builder };
|
||||
|
@ -588,7 +588,7 @@ Optional<KBuffer> procfs$net_local(InodeIdentifier)
|
|||
return builder.build();
|
||||
}
|
||||
|
||||
Optional<KBuffer> procfs$pid_vmobjects(InodeIdentifier identifier)
|
||||
static Optional<KBuffer> procfs$pid_vmobjects(InodeIdentifier identifier)
|
||||
{
|
||||
auto process = Process::from_pid(to_pid(identifier));
|
||||
if (!process)
|
||||
|
@ -623,7 +623,7 @@ Optional<KBuffer> procfs$pid_vmobjects(InodeIdentifier identifier)
|
|||
return builder.build();
|
||||
}
|
||||
|
||||
Optional<KBuffer> procfs$pid_unveil(InodeIdentifier identifier)
|
||||
static Optional<KBuffer> procfs$pid_unveil(InodeIdentifier identifier)
|
||||
{
|
||||
auto process = Process::from_pid(to_pid(identifier));
|
||||
if (!process)
|
||||
|
@ -648,7 +648,7 @@ Optional<KBuffer> procfs$pid_unveil(InodeIdentifier identifier)
|
|||
return builder.build();
|
||||
}
|
||||
|
||||
Optional<KBuffer> procfs$tid_stack(InodeIdentifier identifier)
|
||||
static Optional<KBuffer> procfs$tid_stack(InodeIdentifier identifier)
|
||||
{
|
||||
auto thread = Thread::from_tid(to_tid(identifier));
|
||||
if (!thread)
|
||||
|
@ -659,7 +659,7 @@ Optional<KBuffer> procfs$tid_stack(InodeIdentifier identifier)
|
|||
return builder.build();
|
||||
}
|
||||
|
||||
Optional<KBuffer> procfs$pid_exe(InodeIdentifier identifier)
|
||||
static Optional<KBuffer> procfs$pid_exe(InodeIdentifier identifier)
|
||||
{
|
||||
auto process = Process::from_pid(to_pid(identifier));
|
||||
if (!process)
|
||||
|
@ -669,7 +669,7 @@ Optional<KBuffer> procfs$pid_exe(InodeIdentifier identifier)
|
|||
return custody->absolute_path().to_byte_buffer();
|
||||
}
|
||||
|
||||
Optional<KBuffer> procfs$pid_cwd(InodeIdentifier identifier)
|
||||
static Optional<KBuffer> procfs$pid_cwd(InodeIdentifier identifier)
|
||||
{
|
||||
auto process = Process::from_pid(to_pid(identifier));
|
||||
if (!process)
|
||||
|
@ -677,7 +677,7 @@ Optional<KBuffer> procfs$pid_cwd(InodeIdentifier identifier)
|
|||
return process->current_directory().absolute_path().to_byte_buffer();
|
||||
}
|
||||
|
||||
Optional<KBuffer> procfs$pid_root(InodeIdentifier identifier)
|
||||
static Optional<KBuffer> procfs$pid_root(InodeIdentifier identifier)
|
||||
{
|
||||
auto process = Process::from_pid(to_pid(identifier));
|
||||
if (!process)
|
||||
|
@ -685,7 +685,7 @@ Optional<KBuffer> procfs$pid_root(InodeIdentifier identifier)
|
|||
return process->root_directory_relative_to_global_root().absolute_path().to_byte_buffer();
|
||||
}
|
||||
|
||||
Optional<KBuffer> procfs$self(InodeIdentifier)
|
||||
static Optional<KBuffer> procfs$self(InodeIdentifier)
|
||||
{
|
||||
char buffer[16];
|
||||
sprintf(buffer, "%d", Process::current()->pid().value());
|
||||
|
@ -712,7 +712,7 @@ Optional<KBuffer> procfs$mm(InodeIdentifier)
|
|||
return builder.build();
|
||||
}
|
||||
|
||||
Optional<KBuffer> procfs$dmesg(InodeIdentifier)
|
||||
static Optional<KBuffer> procfs$dmesg(InodeIdentifier)
|
||||
{
|
||||
InterruptDisabler disabler;
|
||||
KBufferBuilder builder;
|
||||
|
@ -721,7 +721,7 @@ Optional<KBuffer> procfs$dmesg(InodeIdentifier)
|
|||
return builder.build();
|
||||
}
|
||||
|
||||
Optional<KBuffer> procfs$mounts(InodeIdentifier)
|
||||
static Optional<KBuffer> procfs$mounts(InodeIdentifier)
|
||||
{
|
||||
// FIXME: This is obviously racy against the VFS mounts changing.
|
||||
KBufferBuilder builder;
|
||||
|
@ -740,7 +740,7 @@ Optional<KBuffer> procfs$mounts(InodeIdentifier)
|
|||
return builder.build();
|
||||
}
|
||||
|
||||
Optional<KBuffer> procfs$df(InodeIdentifier)
|
||||
static Optional<KBuffer> procfs$df(InodeIdentifier)
|
||||
{
|
||||
// FIXME: This is obviously racy against the VFS mounts changing.
|
||||
KBufferBuilder builder;
|
||||
|
@ -767,7 +767,7 @@ Optional<KBuffer> procfs$df(InodeIdentifier)
|
|||
return builder.build();
|
||||
}
|
||||
|
||||
Optional<KBuffer> procfs$cpuinfo(InodeIdentifier)
|
||||
static Optional<KBuffer> procfs$cpuinfo(InodeIdentifier)
|
||||
{
|
||||
KBufferBuilder builder;
|
||||
JsonArraySerializer array { builder };
|
||||
|
@ -815,7 +815,7 @@ Optional<KBuffer> procfs$memstat(InodeIdentifier)
|
|||
return builder.build();
|
||||
}
|
||||
|
||||
Optional<KBuffer> procfs$all(InodeIdentifier)
|
||||
static Optional<KBuffer> procfs$all(InodeIdentifier)
|
||||
{
|
||||
KBufferBuilder builder;
|
||||
JsonArraySerializer array { builder };
|
||||
|
@ -898,7 +898,7 @@ Optional<KBuffer> procfs$all(InodeIdentifier)
|
|||
return builder.build();
|
||||
}
|
||||
|
||||
Optional<KBuffer> procfs$inodes(InodeIdentifier)
|
||||
static Optional<KBuffer> procfs$inodes(InodeIdentifier)
|
||||
{
|
||||
extern InlineLinkedList<Inode>& all_inodes();
|
||||
KBufferBuilder builder;
|
||||
|
|
|
@ -115,7 +115,7 @@ static void load_kernel_sybols_from_data(const KBuffer& buffer)
|
|||
g_kernel_symbols_available = true;
|
||||
}
|
||||
|
||||
NEVER_INLINE void dump_backtrace_impl(FlatPtr base_pointer, bool use_ksyms)
|
||||
NEVER_INLINE static void dump_backtrace_impl(FlatPtr base_pointer, bool use_ksyms)
|
||||
{
|
||||
SmapDisabler disabler;
|
||||
#if 0
|
||||
|
|
|
@ -397,6 +397,8 @@ void Process::dump_regions()
|
|||
MM.dump_kernel_regions();
|
||||
}
|
||||
|
||||
// Make sure the compiler doesn't "optimize away" this function:
|
||||
extern void signal_trampoline_dummy(void);
|
||||
void signal_trampoline_dummy(void)
|
||||
{
|
||||
// The trampoline preserves the current eax, pushes the signal code and
|
||||
|
|
|
@ -109,7 +109,7 @@ static unsigned days_in_years_since_epoch(unsigned year)
|
|||
return days;
|
||||
}
|
||||
|
||||
u8 bcd_to_binary(u8 bcd)
|
||||
static u8 bcd_to_binary(u8 bcd)
|
||||
{
|
||||
return (bcd & 0x0F) + ((bcd >> 4) * 10);
|
||||
}
|
||||
|
|
|
@ -29,13 +29,13 @@
|
|||
|
||||
namespace Kernel {
|
||||
|
||||
void compute_relative_timeout_from_absolute(const timeval& absolute_time, timeval& relative_time)
|
||||
static void compute_relative_timeout_from_absolute(const timeval& absolute_time, timeval& relative_time)
|
||||
{
|
||||
// Convert absolute time to relative time of day.
|
||||
timeval_sub(absolute_time, kgettimeofday(), relative_time);
|
||||
}
|
||||
|
||||
void compute_relative_timeout_from_absolute(const timespec& absolute_time, timeval& relative_time)
|
||||
static void compute_relative_timeout_from_absolute(const timespec& absolute_time, timeval& relative_time)
|
||||
{
|
||||
timeval tv_absolute_time;
|
||||
timespec_to_timeval(absolute_time, tv_absolute_time);
|
||||
|
|
|
@ -359,7 +359,7 @@ enum class DefaultSignalAction {
|
|||
Continue,
|
||||
};
|
||||
|
||||
DefaultSignalAction default_signal_action(u8 signal)
|
||||
static DefaultSignalAction default_signal_action(u8 signal)
|
||||
{
|
||||
ASSERT(signal && signal < NSIG);
|
||||
|
||||
|
|
|
@ -176,7 +176,7 @@ extern "C" int kernelputstr(const char* characters, int length)
|
|||
return 0;
|
||||
}
|
||||
|
||||
extern "C" int vdbgprintf(const char* fmt, va_list ap)
|
||||
static int vdbgprintf(const char* fmt, va_list ap)
|
||||
{
|
||||
ScopedSpinLock lock(s_log_lock);
|
||||
color_on();
|
||||
|
|
Loading…
Reference in a new issue