summaryrefslogtreecommitdiff
path: root/Kernel
diff options
context:
space:
mode:
Diffstat (limited to 'Kernel')
-rw-r--r--Kernel/Console.h3
-rw-r--r--Kernel/DevPtsFS.h2
-rw-r--r--Kernel/KSyms.cpp4
-rw-r--r--Kernel/KSyms.h2
-rw-r--r--Kernel/Keyboard.h2
-rw-r--r--Kernel/MemoryManager.h2
-rw-r--r--Kernel/ProcFS.h2
-rw-r--r--Kernel/Process.h8
-rw-r--r--Kernel/StdLib.cpp3
-rw-r--r--Kernel/TSS.h4
-rw-r--r--Kernel/VirtualFileSystem.h2
-rw-r--r--Kernel/i386.cpp14
-rw-r--r--Kernel/i386.h19
-rw-r--r--Kernel/init.cpp9
-rw-r--r--Kernel/kassert.h2
-rw-r--r--Kernel/kmalloc.cpp12
-rw-r--r--Kernel/kmalloc.h12
-rw-r--r--Kernel/kprintf.h2
-rw-r--r--Kernel/types.h8
19 files changed, 52 insertions, 60 deletions
diff --git a/Kernel/Console.h b/Kernel/Console.h
index 4ef6a4684e..2d3cc77009 100644
--- a/Kernel/Console.h
+++ b/Kernel/Console.h
@@ -1,7 +1,6 @@
#pragma once
#include <AK/CircularQueue.h>
-#include <AK/Compiler.h>
#include <AK/Vector.h>
#include <Kernel/CharacterDevice.h>
@@ -14,7 +13,7 @@ public:
class Console final : public CharacterDevice {
AK_MAKE_ETERNAL
public:
- static Console& the() PURE;
+ static Console& the();
Console();
virtual ~Console() override;
diff --git a/Kernel/DevPtsFS.h b/Kernel/DevPtsFS.h
index 94587e0031..33a08f0c70 100644
--- a/Kernel/DevPtsFS.h
+++ b/Kernel/DevPtsFS.h
@@ -8,7 +8,7 @@ class SlavePTY;
class DevPtsFS final : public SynthFS {
public:
- static DevPtsFS& the() PURE;
+ [[gnu::pure]] static DevPtsFS& the();
virtual ~DevPtsFS() override;
static RetainPtr<DevPtsFS> create();
diff --git a/Kernel/KSyms.cpp b/Kernel/KSyms.cpp
index 9bc26ddb8b..b5913b582c 100644
--- a/Kernel/KSyms.cpp
+++ b/Kernel/KSyms.cpp
@@ -74,11 +74,11 @@ static void load_ksyms_from_data(const ByteBuffer& buffer)
void dump_backtrace(bool use_ksyms)
{
if (!current) {
- HANG;
+ hang();
return;
}
if (use_ksyms && !ksyms_ready) {
- HANG;
+ hang();
return;
}
struct RecognizedSymbol {
diff --git a/Kernel/KSyms.h b/Kernel/KSyms.h
index d0551c5307..a7f8c33fa3 100644
--- a/Kernel/KSyms.h
+++ b/Kernel/KSyms.h
@@ -8,7 +8,7 @@ struct KSym {
const char* name;
};
-const KSym* ksymbolicate(dword address) PURE;
+const KSym* ksymbolicate(dword address);
void load_ksyms();
void init_ksyms();
diff --git a/Kernel/Keyboard.h b/Kernel/Keyboard.h
index 6cf580b801..35bda98164 100644
--- a/Kernel/Keyboard.h
+++ b/Kernel/Keyboard.h
@@ -29,7 +29,7 @@ public:
bool is_press() const { return flags & Is_Press; }
};
- static Keyboard& the() PURE;
+ [[gnu::pure]] static Keyboard& the();
virtual ~Keyboard() override;
Keyboard();
diff --git a/Kernel/MemoryManager.h b/Kernel/MemoryManager.h
index a7243d5b97..4cf90b3df8 100644
--- a/Kernel/MemoryManager.h
+++ b/Kernel/MemoryManager.h
@@ -217,7 +217,7 @@ class MemoryManager {
friend class VMObject;
friend ByteBuffer procfs$mm(InodeIdentifier);
public:
- static MemoryManager& the() PURE;
+ [[gnu::pure]] static MemoryManager& the();
static void initialize();
diff --git a/Kernel/ProcFS.h b/Kernel/ProcFS.h
index 9c5591bff0..c57e08fdd1 100644
--- a/Kernel/ProcFS.h
+++ b/Kernel/ProcFS.h
@@ -11,7 +11,7 @@ class ProcFSInode;
class ProcFS final : public FS {
friend class ProcFSInode;
public:
- static ProcFS& the() PURE;
+ [[gnu::pure]] static ProcFS& the();
virtual ~ProcFS() override;
static RetainPtr<ProcFS> create();
diff --git a/Kernel/Process.h b/Kernel/Process.h
index f030acdf24..66c7528966 100644
--- a/Kernel/Process.h
+++ b/Kernel/Process.h
@@ -171,8 +171,8 @@ public:
int sys$lseek(int fd, off_t, int whence);
int sys$kill(pid_t pid, int sig);
int sys$geterror() { return m_error; }
- void sys$exit(int status) NORETURN;
- void sys$sigreturn() NORETURN;
+ [[noreturn]] void sys$exit(int status);
+ [[noreturn]] void sys$sigreturn();
pid_t sys$waitpid(pid_t, int* wstatus, int options);
void* sys$mmap(const Syscall::SC_mmap_params*);
int sys$munmap(void*, size_t size);
@@ -230,8 +230,8 @@ public:
static void initialize();
- void crash() NORETURN;
- static int reap(Process&) WARN_UNUSED_RESULT;
+ [[noreturn]] void crash();
+ [[nodiscard]] static int reap(Process&);
const TTY* tty() const { return m_tty; }
void set_tty(TTY* tty) { m_tty = tty; }
diff --git a/Kernel/StdLib.cpp b/Kernel/StdLib.cpp
index 87e1df0506..03c02e0ae9 100644
--- a/Kernel/StdLib.cpp
+++ b/Kernel/StdLib.cpp
@@ -125,8 +125,7 @@ int memcmp(const void* v1, const void* v2, size_t n)
return 0;
}
-void __cxa_pure_virtual() NORETURN;
-void __cxa_pure_virtual()
+[[noreturn]] void __cxa_pure_virtual()
{
ASSERT_NOT_REACHED();
}
diff --git a/Kernel/TSS.h b/Kernel/TSS.h
index 676750e454..f3e370439e 100644
--- a/Kernel/TSS.h
+++ b/Kernel/TSS.h
@@ -2,7 +2,7 @@
#include <AK/Types.h>
-struct TSS32 {
+struct [[gnu::packed]] TSS32 {
word backlink, __blh;
dword esp0;
word ss0, __ss0h;
@@ -20,4 +20,4 @@ struct TSS32 {
word gs, __gsh;
word ldt, __ldth;
word trace, iomapbase;
-} PACKED;
+};
diff --git a/Kernel/VirtualFileSystem.h b/Kernel/VirtualFileSystem.h
index 6c3fe71c40..7887005c73 100644
--- a/Kernel/VirtualFileSystem.h
+++ b/Kernel/VirtualFileSystem.h
@@ -54,7 +54,7 @@ public:
RetainPtr<FS> m_guest_fs;
};
- static VFS& the() PURE;
+ [[gnu::pure]] static VFS& the();
VFS();
~VFS();
diff --git a/Kernel/i386.cpp b/Kernel/i386.cpp
index 1336b8aa11..ccf27c9f33 100644
--- a/Kernel/i386.cpp
+++ b/Kernel/i386.cpp
@@ -10,10 +10,10 @@
//#define PAGE_FAULT_DEBUG
-struct DescriptorTablePointer {
+struct [[gnu::packed]] DescriptorTablePointer {
word size;
void* address;
-} PACKED;
+};
static DescriptorTablePointer s_idtr;
static DescriptorTablePointer s_gdtr;
@@ -144,9 +144,9 @@ void exception_6_handler(RegisterDump& regs)
if (current->is_ring0()) {
kprintf("Oh shit, we've crashed in ring 0 :(\n");
- HANG;
+ hang();
}
- HANG;
+ hang();
current->crash();
}
@@ -219,7 +219,7 @@ void exception_13_handler(RegisterDumpWithExceptionCode& regs)
if (current->is_ring0()) {
kprintf("Oh shit, we've crashed in ring 0 :(\n");
- HANG;
+ hang();
}
current->crash();
@@ -313,7 +313,7 @@ void exception_14_handler(RegisterDumpWithExceptionCode& regs)
asm ("movl %%cr3, %%eax":"=a"(cr3)); \
asm ("movl %%cr4, %%eax":"=a"(cr4)); \
kprintf("CR0=%x CR2=%x CR3=%x CR4=%x\n", cr0, cr2, cr3, cr4); \
- HANG; \
+ hang(); \
}
EH(0, "Divide error")
@@ -385,7 +385,7 @@ void gdt_init()
static void unimp_trap()
{
kprintf("Unhandled IRQ.");
- HANG;
+ hang();
}
void register_irq_handler(byte irq, IRQHandler& handler)
diff --git a/Kernel/i386.h b/Kernel/i386.h
index bede94a97c..4dc56620d4 100644
--- a/Kernel/i386.h
+++ b/Kernel/i386.h
@@ -6,7 +6,7 @@
#define PAGE_SIZE 4096
#define PAGE_MASK 0xfffff000
-union Descriptor {
+union [[gnu::packed]] Descriptor {
struct {
word limit_lo;
word base_lo;
@@ -55,7 +55,7 @@ union Descriptor {
limit_lo = (dword)l & 0xffff;
limit_hi = ((dword)l >> 16) & 0xff;
}
-} PACKED;
+};
class IRQHandler;
@@ -73,7 +73,12 @@ void gdt_free_entry(word);
Descriptor& get_gdt_entry(word selector);
void write_gdt_entry(word selector, Descriptor&);
-#define HANG asm volatile( "cli; hlt" );
+[[noreturn]] static inline void hang()
+{
+ asm volatile("cli; hlt");
+ for (;;) { }
+}
+
#define LSW(x) ((dword)(x) & 0xFFFF)
#define MSW(x) (((dword)(x) >> 16) & 0xFFFF)
#define LSB(x) ((x) & 0xFF)
@@ -182,7 +187,7 @@ private:
LinearAddress m_laddr;
};
-struct RegisterDump {
+struct [[gnu::packed]] RegisterDump {
word ss;
word gs;
word fs;
@@ -202,9 +207,9 @@ struct RegisterDump {
dword eflags;
dword esp_if_crossRing;
word ss_if_crossRing;
-} PACKED;
+};
-struct RegisterDumpWithExceptionCode {
+struct [[gnu::packed]] RegisterDumpWithExceptionCode {
word ss;
word gs;
word fs;
@@ -226,7 +231,7 @@ struct RegisterDumpWithExceptionCode {
dword eflags;
dword esp_if_crossRing;
word ss_if_crossRing;
-} PACKED;
+};
struct FPUState {
dword cwd;
diff --git a/Kernel/init.cpp b/Kernel/init.cpp
index 632c00b2f4..2c68fc80bd 100644
--- a/Kernel/init.cpp
+++ b/Kernel/init.cpp
@@ -44,8 +44,7 @@ NullDevice* dev_null;
VFS* vfs;
#ifdef STRESS_TEST_SPAWNING
-static void spawn_stress() NORETURN;
-static void spawn_stress()
+[[noreturn]] static void spawn_stress()
{
dword last_sum_alloc = sum_alloc;
@@ -62,8 +61,7 @@ static void spawn_stress()
}
#endif
-static void init_stage2() NORETURN;
-static void init_stage2()
+[[noreturn]] static void init_stage2()
{
Syscall::initialize();
@@ -135,8 +133,7 @@ static void init_stage2()
ASSERT_NOT_REACHED();
}
-void init() NORETURN;
-void init()
+[[noreturn]] void init()
{
cli();
diff --git a/Kernel/kassert.h b/Kernel/kassert.h
index f799f90c72..774afe2a62 100644
--- a/Kernel/kassert.h
+++ b/Kernel/kassert.h
@@ -3,7 +3,7 @@
#include "kprintf.h"
#include "i386.h"
-void __assertion_failed(const char* msg, const char* file, unsigned line, const char* func) NORETURN;
+[[noreturn]] void __assertion_failed(const char* msg, const char* file, unsigned line, const char* func);
#define ASSERT(expr) (static_cast<bool>(expr) ? (void)0 : __assertion_failed(#expr, __FILE__, __LINE__, __PRETTY_FUNCTION__))
#define CRASH() do { asm volatile("ud2"); } while(0)
diff --git a/Kernel/kmalloc.cpp b/Kernel/kmalloc.cpp
index a61a1b48a0..2447914459 100644
--- a/Kernel/kmalloc.cpp
+++ b/Kernel/kmalloc.cpp
@@ -14,11 +14,10 @@
#define SANITIZE_KMALLOC
-typedef struct
-{
+struct [[gnu::packed]] allocation_t {
dword start;
dword nchunk;
-} PACKED allocation_t;
+};
#define CHUNK_SIZE 128
#define POOL_SIZE (1024 * 1024)
@@ -103,8 +102,7 @@ void* kmalloc_impl(dword size)
if (sum_free < real_size) {
kprintf("%s<%u> kmalloc(): PANIC! Out of memory (sucks, dude)\nsum_free=%u, real_size=%x\n", current->name().characters(), current->pid(), sum_free, real_size);
- HANG;
- return 0L;
+ hang();
}
chunks_needed = real_size / CHUNK_SIZE;
@@ -164,9 +162,7 @@ void* kmalloc_impl(dword size)
}
kprintf("%s<%u> kmalloc(): PANIC! Out of memory (no suitable block for size %u)\n", current->name().characters(), current->pid(), size);
- HANG;
-
- return nullptr;
+ hang();
}
void kfree(void *ptr)
diff --git a/Kernel/kmalloc.h b/Kernel/kmalloc.h
index 82c47e3354..19e9fb9644 100644
--- a/Kernel/kmalloc.h
+++ b/Kernel/kmalloc.h
@@ -1,12 +1,14 @@
#pragma once
+#include <AK/Types.h>
+
//#define KMALLOC_DEBUG_LARGE_ALLOCATIONS
void kmalloc_init();
-void* kmalloc_impl(dword size) __attribute__ ((malloc));
-void* kmalloc_eternal(size_t) __attribute__ ((malloc));
-void* kmalloc_page_aligned(size_t) __attribute__ ((malloc));
-void* kmalloc_aligned(size_t, size_t alignment) __attribute__ ((malloc));
+[[gnu::malloc, gnu::returns_nonnull, gnu::alloc_size(1)]] void* kmalloc_impl(size_t);
+[[gnu::malloc, gnu::returns_nonnull, gnu::alloc_size(1)]] void* kmalloc_eternal(size_t);
+[[gnu::malloc, gnu::returns_nonnull, gnu::alloc_size(1)]] void* kmalloc_page_aligned(size_t);
+[[gnu::malloc, gnu::returns_nonnull, gnu::alloc_size(1)]] void* kmalloc_aligned(size_t, size_t alignment);
void kfree(void*);
void kfree_aligned(void*);
@@ -20,7 +22,7 @@ extern volatile size_t kmalloc_sum_page_aligned;
inline void* operator new(size_t, void* p) { return p; }
inline void* operator new[](size_t, void* p) { return p; }
-ALWAYS_INLINE void* kmalloc(size_t size)
+[[gnu::always_inline]] inline void* kmalloc(size_t size)
{
#ifdef KMALLOC_DEBUG_LARGE_ALLOCATIONS
// Any kernel allocation >= 1M is 99.9% a bug.
diff --git a/Kernel/kprintf.h b/Kernel/kprintf.h
index 2406b9c07d..29c2d15bd4 100644
--- a/Kernel/kprintf.h
+++ b/Kernel/kprintf.h
@@ -1,7 +1,5 @@
#pragma once
-#include <AK/Compiler.h>
-
extern "C" {
int dbgprintf(const char *fmt, ...);
int kprintf(const char *fmt, ...);
diff --git a/Kernel/types.h b/Kernel/types.h
index 45cd0bb45d..efa5a31977 100644
--- a/Kernel/types.h
+++ b/Kernel/types.h
@@ -1,11 +1,7 @@
#pragma once
-#include <AK/Compiler.h>
#include <AK/Types.h>
-#define PACKED __attribute__ ((packed))
-#define PURE __attribute__ ((pure))
-
typedef dword __u32;
typedef word __u16;
typedef byte __u8;
@@ -43,10 +39,10 @@ typedef dword nlink_t;
typedef dword blksize_t;
typedef dword blkcnt_t;
-struct FarPtr {
+struct [[gnu::packed]] FarPtr {
dword offset { 0 };
word selector { 0 };
-} PACKED;
+};
class PhysicalAddress {
public: