From c7ab6bc2d3942035be500f2a9a80c8ce625c80d2 Mon Sep 17 00:00:00 2001 From: apio Date: Sun, 4 Dec 2022 12:42:43 +0100 Subject: [PATCH] Reorganize the luna/ directory so that headers aren't in the top level include path --- kernel/src/Log.cpp | 2 +- kernel/src/Log.h | 4 ++-- kernel/src/arch/CPU.h | 2 +- kernel/src/arch/MMU.h | 2 +- kernel/src/arch/Serial.cpp | 2 +- kernel/src/arch/Serial.h | 4 ++-- kernel/src/arch/Timer.cpp | 2 +- kernel/src/arch/Timer.h | 2 +- kernel/src/arch/x86_64/CPU.cpp | 6 +++--- kernel/src/arch/x86_64/CPU.h | 2 +- kernel/src/arch/x86_64/IO.h | 2 +- kernel/src/arch/x86_64/MMU.cpp | 4 ++-- kernel/src/boot/Init.cpp | 2 +- kernel/src/main.cpp | 2 +- kernel/src/memory/Heap.cpp | 6 +++--- kernel/src/memory/Heap.h | 4 ++-- kernel/src/memory/MemoryManager.cpp | 8 ++++---- kernel/src/memory/MemoryManager.h | 4 ++-- kernel/src/video/BuiltinFont.h | 2 +- kernel/src/video/Framebuffer.h | 2 +- kernel/src/video/TextConsole.cpp | 4 ++-- kernel/src/video/TextConsole.h | 6 +++--- luna/CMakeLists.txt | 16 ++++++++-------- luna/{ => include/luna}/Alignment.h | 0 luna/{ => include/luna}/Attributes.h | 0 luna/{ => include/luna}/CType.h | 0 luna/{ => include/luna}/Check.h | 2 +- luna/{ => include/luna}/Format.h | 4 ++-- luna/{ => include/luna}/Move.h | 0 luna/{ => include/luna}/NumberParsing.h | 3 +-- luna/{ => include/luna}/PlacementNew.h | 2 +- luna/{ => include/luna}/Result.h | 10 +++++----- luna/{ => include/luna}/String.h | 2 +- luna/{ => include/luna}/SystemError.h | 0 luna/{ => include/luna}/Types.h | 0 luna/{ => include/luna}/Units.h | 2 +- luna/{ => src}/Check.cpp | 2 +- luna/{ => src}/Format.cpp | 6 +++--- luna/{ => src}/NumberParsing.cpp | 3 ++- luna/{ => src}/String.cpp | 2 +- luna/{ => src}/SystemError.cpp | 2 +- luna/{ => src}/Units.cpp | 4 ++-- tools/check-formatting.sh | 3 ++- tools/check-stdint.sh | 3 ++- tools/replace-stdint.sh | 3 ++- tools/run-clang-format.sh | 3 ++- 46 files changed, 75 insertions(+), 71 deletions(-) rename luna/{ => include/luna}/Alignment.h (100%) rename luna/{ => include/luna}/Attributes.h (100%) rename luna/{ => include/luna}/CType.h (100%) rename luna/{ => include/luna}/Check.h (95%) rename luna/{ => include/luna}/Format.h (83%) rename luna/{ => include/luna}/Move.h (100%) rename luna/{ => include/luna}/NumberParsing.h (84%) rename luna/{ => include/luna}/PlacementNew.h (72%) rename luna/{ => include/luna}/Result.h (97%) rename luna/{ => include/luna}/String.h (91%) rename luna/{ => include/luna}/SystemError.h (100%) rename luna/{ => include/luna}/Types.h (100%) rename luna/{ => include/luna}/Units.h (72%) rename luna/{ => src}/Check.cpp (79%) rename luna/{ => src}/Format.cpp (99%) rename luna/{ => src}/NumberParsing.cpp (96%) rename luna/{ => src}/String.cpp (97%) rename luna/{ => src}/SystemError.cpp (98%) rename luna/{ => src}/Units.cpp (88%) diff --git a/kernel/src/Log.cpp b/kernel/src/Log.cpp index 67704922..b4f14cc7 100644 --- a/kernel/src/Log.cpp +++ b/kernel/src/Log.cpp @@ -3,7 +3,7 @@ #include "arch/Serial.h" #include "arch/Timer.h" #include "video/TextConsole.h" -#include +#include static bool g_debug_enabled = true; static bool g_serial_enabled = true; diff --git a/kernel/src/Log.h b/kernel/src/Log.h index 0c0b9ab8..10eaed9f 100644 --- a/kernel/src/Log.h +++ b/kernel/src/Log.h @@ -1,6 +1,6 @@ #pragma once -#include -#include +#include +#include #include enum class LogLevel diff --git a/kernel/src/arch/CPU.h b/kernel/src/arch/CPU.h index 1558551a..abf826e3 100644 --- a/kernel/src/arch/CPU.h +++ b/kernel/src/arch/CPU.h @@ -1,5 +1,5 @@ #pragma once -#include +#include struct Registers; diff --git a/kernel/src/arch/MMU.h b/kernel/src/arch/MMU.h index d15c7b87..f18e0302 100644 --- a/kernel/src/arch/MMU.h +++ b/kernel/src/arch/MMU.h @@ -1,5 +1,5 @@ #pragma once -#include +#include struct PageDirectory; diff --git a/kernel/src/arch/Serial.cpp b/kernel/src/arch/Serial.cpp index 2dc834ac..2282d157 100644 --- a/kernel/src/arch/Serial.cpp +++ b/kernel/src/arch/Serial.cpp @@ -1,6 +1,6 @@ #include "arch/Serial.h" #include "arch/CPU.h" -#include +#include namespace Serial { diff --git a/kernel/src/arch/Serial.h b/kernel/src/arch/Serial.h index 097a7408..0efc6e47 100644 --- a/kernel/src/arch/Serial.h +++ b/kernel/src/arch/Serial.h @@ -1,6 +1,6 @@ #pragma once -#include -#include +#include +#include template class Result; diff --git a/kernel/src/arch/Timer.cpp b/kernel/src/arch/Timer.cpp index d2ac041e..9c0606db 100644 --- a/kernel/src/arch/Timer.cpp +++ b/kernel/src/arch/Timer.cpp @@ -2,7 +2,7 @@ #include "Log.h" #include "arch/Serial.h" #include "boot/bootboot.h" -#include +#include static u64 timer_ticks = 0; static u64 boot_timestamp; diff --git a/kernel/src/arch/Timer.h b/kernel/src/arch/Timer.h index d2895de3..21c389d7 100644 --- a/kernel/src/arch/Timer.h +++ b/kernel/src/arch/Timer.h @@ -1,5 +1,5 @@ #pragma once -#include +#include extern const usize ARCH_TIMER_FREQ; // How many timer ticks in one millisecond? diff --git a/kernel/src/arch/x86_64/CPU.cpp b/kernel/src/arch/x86_64/CPU.cpp index d5a7ee3d..306117d5 100644 --- a/kernel/src/arch/x86_64/CPU.cpp +++ b/kernel/src/arch/x86_64/CPU.cpp @@ -3,10 +3,10 @@ #include "arch/Serial.h" #include "arch/Timer.h" #include "arch/x86_64/IO.h" -#include -#include -#include #include +#include +#include +#include extern "C" void enable_sse(); extern "C" void enable_write_protect(); diff --git a/kernel/src/arch/x86_64/CPU.h b/kernel/src/arch/x86_64/CPU.h index f156e80d..a4e8d52f 100644 --- a/kernel/src/arch/x86_64/CPU.h +++ b/kernel/src/arch/x86_64/CPU.h @@ -1,5 +1,5 @@ #include "arch/CPU.h" -#include +#include struct Registers // Saved CPU registers for x86-64 { diff --git a/kernel/src/arch/x86_64/IO.h b/kernel/src/arch/x86_64/IO.h index 05c6acf9..5f5a6fc2 100644 --- a/kernel/src/arch/x86_64/IO.h +++ b/kernel/src/arch/x86_64/IO.h @@ -1,5 +1,5 @@ #pragma once -#include +#include namespace IO { diff --git a/kernel/src/arch/x86_64/MMU.cpp b/kernel/src/arch/x86_64/MMU.cpp index a36a038e..12cbd372 100644 --- a/kernel/src/arch/x86_64/MMU.cpp +++ b/kernel/src/arch/x86_64/MMU.cpp @@ -1,7 +1,7 @@ #include "arch/MMU.h" #include "memory/MemoryManager.h" -#include -#include +#include +#include #define PAGE_SIZE 4096 diff --git a/kernel/src/boot/Init.cpp b/kernel/src/boot/Init.cpp index 0654f8a9..18a3e8d0 100644 --- a/kernel/src/boot/Init.cpp +++ b/kernel/src/boot/Init.cpp @@ -5,7 +5,7 @@ #include "boot/bootboot.h" #include "memory/MemoryManager.h" #include "video/Framebuffer.h" -#include +#include extern BOOTBOOT bootboot; diff --git a/kernel/src/main.cpp b/kernel/src/main.cpp index 3e5cba2c..9c804132 100644 --- a/kernel/src/main.cpp +++ b/kernel/src/main.cpp @@ -8,7 +8,7 @@ #include "memory/Heap.h" #include "memory/MemoryManager.h" #include "video/TextConsole.h" -#include +#include Result init() { diff --git a/kernel/src/memory/Heap.cpp b/kernel/src/memory/Heap.cpp index d98a205d..6c7a4bad 100644 --- a/kernel/src/memory/Heap.cpp +++ b/kernel/src/memory/Heap.cpp @@ -3,9 +3,9 @@ #include "arch/MMU.h" #include "arch/Serial.h" #include "memory/MemoryManager.h" -#include -#include -#include +#include +#include +#include static constexpr int BLOCK_USED = 1 << 0; static constexpr int BLOCK_START_MEM = 1 << 1; diff --git a/kernel/src/memory/Heap.h b/kernel/src/memory/Heap.h index 251e039c..80d4b410 100644 --- a/kernel/src/memory/Heap.h +++ b/kernel/src/memory/Heap.h @@ -1,6 +1,6 @@ #pragma once -#include -#include +#include +#include Result kmalloc(usize size); Result kcalloc(usize nmemb, usize size); diff --git a/kernel/src/memory/MemoryManager.cpp b/kernel/src/memory/MemoryManager.cpp index 65d9006d..9bbd204c 100644 --- a/kernel/src/memory/MemoryManager.cpp +++ b/kernel/src/memory/MemoryManager.cpp @@ -2,10 +2,10 @@ #include "Log.h" #include "arch/MMU.h" #include "boot/bootboot.h" -#include -#include -#include -#include +#include +#include +#include +#include extern BOOTBOOT bootboot; diff --git a/kernel/src/memory/MemoryManager.h b/kernel/src/memory/MemoryManager.h index f311f412..8179e12e 100644 --- a/kernel/src/memory/MemoryManager.h +++ b/kernel/src/memory/MemoryManager.h @@ -1,6 +1,6 @@ #pragma once -#include -#include +#include +#include namespace MemoryManager { diff --git a/kernel/src/video/BuiltinFont.h b/kernel/src/video/BuiltinFont.h index a2a2e478..cadd6908 100644 --- a/kernel/src/video/BuiltinFont.h +++ b/kernel/src/video/BuiltinFont.h @@ -1,5 +1,5 @@ #pragma once -#include +#include // FIXME: Load a font from disk/initrd. diff --git a/kernel/src/video/Framebuffer.h b/kernel/src/video/Framebuffer.h index 9105f315..033ac127 100644 --- a/kernel/src/video/Framebuffer.h +++ b/kernel/src/video/Framebuffer.h @@ -1,5 +1,5 @@ #pragma once -#include +#include namespace Framebuffer { diff --git a/kernel/src/video/TextConsole.cpp b/kernel/src/video/TextConsole.cpp index 5e6b46f3..8384eec5 100644 --- a/kernel/src/video/TextConsole.cpp +++ b/kernel/src/video/TextConsole.cpp @@ -1,8 +1,8 @@ #include "video/TextConsole.h" #include "boot/bootboot.h" #include "video/Framebuffer.h" -#include -#include +#include +#include extern BOOTBOOT bootboot; diff --git a/kernel/src/video/TextConsole.h b/kernel/src/video/TextConsole.h index 62dfb51f..d502e485 100644 --- a/kernel/src/video/TextConsole.h +++ b/kernel/src/video/TextConsole.h @@ -1,7 +1,7 @@ #pragma once -#include -#include -#include +#include +#include +#include namespace TextConsole { diff --git a/luna/CMakeLists.txt b/luna/CMakeLists.txt index 8360aef4..0bb23007 100644 --- a/luna/CMakeLists.txt +++ b/luna/CMakeLists.txt @@ -1,14 +1,14 @@ set(FREESTANDING_SOURCES - Format.cpp - NumberParsing.cpp - String.cpp - Units.cpp - SystemError.cpp + src/Format.cpp + src/NumberParsing.cpp + src/String.cpp + src/Units.cpp + src/SystemError.cpp ) set(SOURCES ${FREESTANDING_SOURCES} - Check.cpp + src/Check.cpp ) add_library(luna-freestanding ${FREESTANDING_SOURCES}) @@ -26,7 +26,7 @@ target_compile_options(luna-freestanding PRIVATE -mno-red-zone) target_compile_options(luna-freestanding PRIVATE -mno-80387 -mno-mmx -mno-sse -mno-sse2) endif() -target_include_directories(luna-freestanding PUBLIC ${LUNA_ROOT}/luna) +target_include_directories(luna-freestanding PUBLIC include/) set_target_properties(luna-freestanding PROPERTIES CXX_STANDARD 20) add_library(luna ${SOURCES}) @@ -35,5 +35,5 @@ target_compile_options(luna PRIVATE -Wdisabled-optimization -Wformat=2 -Winit-se target_compile_options(luna PRIVATE -Wmissing-include-dirs -Wswitch-default -Wcast-qual -Wundef) target_compile_options(luna PRIVATE -Wcast-align -Wwrite-strings -Wlogical-op -Wredundant-decls -Wshadow -Wconversion) target_compile_options(luna PRIVATE -fno-asynchronous-unwind-tables -fno-omit-frame-pointer) -target_include_directories(luna PUBLIC ${LUNA_ROOT}/luna) +target_include_directories(luna PUBLIC include/) set_target_properties(luna PROPERTIES CXX_STANDARD 20) \ No newline at end of file diff --git a/luna/Alignment.h b/luna/include/luna/Alignment.h similarity index 100% rename from luna/Alignment.h rename to luna/include/luna/Alignment.h diff --git a/luna/Attributes.h b/luna/include/luna/Attributes.h similarity index 100% rename from luna/Attributes.h rename to luna/include/luna/Attributes.h diff --git a/luna/CType.h b/luna/include/luna/CType.h similarity index 100% rename from luna/CType.h rename to luna/include/luna/CType.h diff --git a/luna/Check.h b/luna/include/luna/Check.h similarity index 95% rename from luna/Check.h rename to luna/include/luna/Check.h index 429e65af..fce54b96 100644 --- a/luna/Check.h +++ b/luna/include/luna/Check.h @@ -1,5 +1,5 @@ #pragma once -#include +#include extern _noreturn bool __check_failed(const char* file, const char* line, const char* func, const char* expr); diff --git a/luna/Format.h b/luna/include/luna/Format.h similarity index 83% rename from luna/Format.h rename to luna/include/luna/Format.h index 3ad779f2..245979a7 100644 --- a/luna/Format.h +++ b/luna/include/luna/Format.h @@ -1,6 +1,6 @@ #pragma once -#include -#include +#include +#include #include typedef Result (*callback_t)(char, void*); diff --git a/luna/Move.h b/luna/include/luna/Move.h similarity index 100% rename from luna/Move.h rename to luna/include/luna/Move.h diff --git a/luna/NumberParsing.h b/luna/include/luna/NumberParsing.h similarity index 84% rename from luna/NumberParsing.h rename to luna/include/luna/NumberParsing.h index c3c83fce..774250a1 100644 --- a/luna/NumberParsing.h +++ b/luna/include/luna/NumberParsing.h @@ -1,6 +1,5 @@ #pragma once -#include -#include +#include usize _atou(const char** str); isize _atos(const char** str); diff --git a/luna/PlacementNew.h b/luna/include/luna/PlacementNew.h similarity index 72% rename from luna/PlacementNew.h rename to luna/include/luna/PlacementNew.h index 4ecf821c..91a20f39 100644 --- a/luna/PlacementNew.h +++ b/luna/include/luna/PlacementNew.h @@ -1,5 +1,5 @@ #pragma once -#include +#include inline void* operator new(usize, void* p) noexcept { diff --git a/luna/Result.h b/luna/include/luna/Result.h similarity index 97% rename from luna/Result.h rename to luna/include/luna/Result.h index 297fdec1..a923bff4 100644 --- a/luna/Result.h +++ b/luna/include/luna/Result.h @@ -1,9 +1,9 @@ #pragma once -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include struct Error { diff --git a/luna/String.h b/luna/include/luna/String.h similarity index 91% rename from luna/String.h rename to luna/include/luna/String.h index 1e2b9a81..0dddc00b 100644 --- a/luna/String.h +++ b/luna/include/luna/String.h @@ -1,5 +1,5 @@ #pragma once -#include +#include extern "C" { diff --git a/luna/SystemError.h b/luna/include/luna/SystemError.h similarity index 100% rename from luna/SystemError.h rename to luna/include/luna/SystemError.h diff --git a/luna/Types.h b/luna/include/luna/Types.h similarity index 100% rename from luna/Types.h rename to luna/include/luna/Types.h diff --git a/luna/Units.h b/luna/include/luna/Units.h similarity index 72% rename from luna/Units.h rename to luna/include/luna/Units.h index c12aac63..854c18b8 100644 --- a/luna/Units.h +++ b/luna/include/luna/Units.h @@ -1,4 +1,4 @@ #pragma once -#include +#include Result to_dynamic_unit(usize value, char* buffer, usize max); \ No newline at end of file diff --git a/luna/Check.cpp b/luna/src/Check.cpp similarity index 79% rename from luna/Check.cpp rename to luna/src/Check.cpp index e464ca86..4f522f79 100644 --- a/luna/Check.cpp +++ b/luna/src/Check.cpp @@ -1,4 +1,4 @@ -#include +#include _weak _noreturn bool __check_failed(const char*, const char*, const char*, const char*) { diff --git a/luna/Format.cpp b/luna/src/Format.cpp similarity index 99% rename from luna/Format.cpp rename to luna/src/Format.cpp index f3b1c62a..0231b3a2 100644 --- a/luna/Format.cpp +++ b/luna/src/Format.cpp @@ -1,6 +1,6 @@ -#include -#include -#include +#include +#include +#include extern "C" usize strlen(const char*); diff --git a/luna/NumberParsing.cpp b/luna/src/NumberParsing.cpp similarity index 96% rename from luna/NumberParsing.cpp rename to luna/src/NumberParsing.cpp index 0e46b314..0790ad9f 100644 --- a/luna/NumberParsing.cpp +++ b/luna/src/NumberParsing.cpp @@ -1,4 +1,5 @@ -#include +#include +#include // This function assumes you have called is_valid_digit_for_base() to validate the digit first. static isize parse_digit_unchecked(char c) diff --git a/luna/String.cpp b/luna/src/String.cpp similarity index 97% rename from luna/String.cpp rename to luna/src/String.cpp index abada229..bd174d93 100644 --- a/luna/String.cpp +++ b/luna/src/String.cpp @@ -1,4 +1,4 @@ -#include +#include extern "C" { diff --git a/luna/SystemError.cpp b/luna/src/SystemError.cpp similarity index 98% rename from luna/SystemError.cpp rename to luna/src/SystemError.cpp index 00719b56..2e1f63ad 100644 --- a/luna/SystemError.cpp +++ b/luna/src/SystemError.cpp @@ -1,4 +1,4 @@ -#include +#include const char* error_string(int error) { diff --git a/luna/Units.cpp b/luna/src/Units.cpp similarity index 88% rename from luna/Units.cpp rename to luna/src/Units.cpp index 1ce0208c..fa2a0e1b 100644 --- a/luna/Units.cpp +++ b/luna/src/Units.cpp @@ -1,5 +1,5 @@ -#include -#include +#include +#include Result to_dynamic_unit(usize value, char* buffer, size_t max) { diff --git a/tools/check-formatting.sh b/tools/check-formatting.sh index bea7f2a8..029a3a05 100755 --- a/tools/check-formatting.sh +++ b/tools/check-formatting.sh @@ -5,7 +5,8 @@ source $(dirname $0)/env.sh cd $LUNA_ROOT SOURCES=($(find kernel/src -type f | grep -v "\.asm")) -SOURCES+=($(find luna -type f | grep -v "CMakeLists.txt")) +SOURCES+=($(find luna/src -type f)) +SOURCES+=($(find luna/include/luna -type f)) ALL_OK=1 diff --git a/tools/check-stdint.sh b/tools/check-stdint.sh index bf78b6d2..8bd9cfb4 100755 --- a/tools/check-stdint.sh +++ b/tools/check-stdint.sh @@ -6,7 +6,8 @@ source $(dirname $0)/env.sh cd $LUNA_ROOT SOURCES=($(find kernel/src -type f | grep -v "\.asm" | grep -v "bootboot.h")) -SOURCES+=($(find luna -type f | grep -v "CMakeLists.txt" | grep -v "Types.h")) +SOURCES+=($(find luna/src -type f)) +SOURCES+=($(find luna/include/luna -type f | grep -v "Types.h")) SUCCESS=1 diff --git a/tools/replace-stdint.sh b/tools/replace-stdint.sh index 2fa4d5a2..2b42c24a 100755 --- a/tools/replace-stdint.sh +++ b/tools/replace-stdint.sh @@ -6,7 +6,8 @@ source $(dirname $0)/env.sh cd $LUNA_ROOT SOURCES=($(find kernel/src -type f | grep -v "\.asm" | grep -v "bootboot.h")) -SOURCES+=($(find luna -type f | grep -v "CMakeLists.txt" | grep -v "Types.h")) +SOURCES+=($(find luna/src -type f)) +SOURCES+=($(find luna/include/luna -type f | grep -v "Types.h")) for f in ${SOURCES[@]} do diff --git a/tools/run-clang-format.sh b/tools/run-clang-format.sh index 2e69fa67..eed14fac 100755 --- a/tools/run-clang-format.sh +++ b/tools/run-clang-format.sh @@ -6,7 +6,8 @@ source $(dirname $0)/env.sh cd $LUNA_ROOT SOURCES=($(find kernel/src -type f | grep -v "\.asm")) -SOURCES+=($(find luna -type f | grep -v "CMakeLists.txt")) +SOURCES+=($(find luna/src -type f)) +SOURCES+=($(find luna/include/luna -type f)) for f in ${SOURCES[@]} do