From 071768e42ff47f9790e238bafd619a9ebfec2af7 Mon Sep 17 00:00:00 2001 From: "Zone.N" Date: Wed, 7 Aug 2024 09:43:04 +0000 Subject: [PATCH] refactor: rename std::ostream with sk_std:: Signed-off-by: Zone.N --- src/kernel/arch/aarch64/include/cpu.hpp | 2 +- src/kernel/arch/riscv64/arch_main.cpp | 2 +- src/kernel/arch/riscv64/include/cpu.hpp | 2 +- src/kernel/arch/x86_64/arch_main.cpp | 2 +- src/kernel/arch/x86_64/include/cpu.hpp | 2 +- src/kernel/include/basic_info.hpp | 4 ++-- src/kernel/include/kernel_log.hpp | 2 +- src/kernel/libcxx/include/cstring | 4 ++-- src/kernel/libcxx/include/iostream | 4 ++-- src/kernel/libcxx/iostream.cpp | 4 ++-- src/kernel/main.cpp | 2 +- 11 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/kernel/arch/aarch64/include/cpu.hpp b/src/kernel/arch/aarch64/include/cpu.hpp index c48d5ce3..73b6dbbc 100644 --- a/src/kernel/arch/aarch64/include/cpu.hpp +++ b/src/kernel/arch/aarch64/include/cpu.hpp @@ -148,7 +148,7 @@ class ReadWriteRegBase : public ReadOnlyRegBase, // 第三部分:寄存器实例 class X29 : public ReadWriteRegBase { public: - friend std::ostream &operator<<(std::ostream &os, const X29 &x29) { + friend sk_std::ostream &operator<<(sk_std::ostream &os, const X29 &x29) { printf("val: 0x%p", (void *)x29.Read()); return os; } diff --git a/src/kernel/arch/riscv64/arch_main.cpp b/src/kernel/arch/riscv64/arch_main.cpp index a53d751c..1fe288c1 100644 --- a/src/kernel/arch/riscv64/arch_main.cpp +++ b/src/kernel/arch/riscv64/arch_main.cpp @@ -58,7 +58,7 @@ uint32_t ArchInit(uint32_t argc, uint8_t *argv) { kKernelFdt.GetInstance() = KernelFdt((uint64_t)argv); kBasicInfo.GetInstance() = BasicInfo(argc, argv); - std::cout << kBasicInfo.GetInstance(); + sk_std::cout << kBasicInfo.GetInstance(); auto [serial_base, serial_size] = kKernelFdt.GetInstance().GetSerial(); auto uart = Ns16550a(serial_base); diff --git a/src/kernel/arch/riscv64/include/cpu.hpp b/src/kernel/arch/riscv64/include/cpu.hpp index 9bdc5be5..78f631a3 100644 --- a/src/kernel/arch/riscv64/include/cpu.hpp +++ b/src/kernel/arch/riscv64/include/cpu.hpp @@ -148,7 +148,7 @@ class ReadWriteRegBase : public ReadOnlyRegBase, // 第三部分:寄存器实例 class Fp : public ReadWriteRegBase { public: - friend std::ostream &operator<<(std::ostream &os, const Fp &fp) { + friend sk_std::ostream &operator<<(sk_std::ostream &os, const Fp &fp) { printf("val: 0x%p", (void *)fp.Read()); return os; } diff --git a/src/kernel/arch/x86_64/arch_main.cpp b/src/kernel/arch/x86_64/arch_main.cpp index 9fcef176..1fffd8ab 100644 --- a/src/kernel/arch/x86_64/arch_main.cpp +++ b/src/kernel/arch/x86_64/arch_main.cpp @@ -59,7 +59,7 @@ uint32_t ArchInit(uint32_t argc, uint8_t *argv) { } kBasicInfo.GetInstance() = BasicInfo(argc, argv); - std::cout << kBasicInfo.GetInstance(); + sk_std::cout << kBasicInfo.GetInstance(); // 解析内核 elf 信息 kKernelElf.GetInstance() = KernelElf(kBasicInfo.GetInstance().elf_addr, diff --git a/src/kernel/arch/x86_64/include/cpu.hpp b/src/kernel/arch/x86_64/include/cpu.hpp index 6c7c51c3..c87a9e66 100644 --- a/src/kernel/arch/x86_64/include/cpu.hpp +++ b/src/kernel/arch/x86_64/include/cpu.hpp @@ -298,7 +298,7 @@ class ReadWriteRegBase : public ReadOnlyRegBase, // 第三部分:寄存器实例 class Rbp : public ReadWriteRegBase { public: - friend std::ostream &operator<<(std::ostream &os, const Rbp &rbp) { + friend sk_std::ostream &operator<<(sk_std::ostream &os, const Rbp &rbp) { printf("val: 0x%p", (void *)rbp.Read()); return os; } diff --git a/src/kernel/include/basic_info.hpp b/src/kernel/include/basic_info.hpp index 27badcbe..97bee594 100644 --- a/src/kernel/include/basic_info.hpp +++ b/src/kernel/include/basic_info.hpp @@ -60,8 +60,8 @@ struct BasicInfo { ~BasicInfo() = default; /// @} - friend std::ostream &operator<<(std::ostream &os, - const BasicInfo &basic_info) { + friend sk_std::ostream &operator<<(sk_std::ostream &os, + const BasicInfo &basic_info) { printf("physical_memory_addr: 0x%X, size 0x%X.\n", basic_info.physical_memory_addr, basic_info.physical_memory_size); printf("kernel_addr: 0x%X, size 0x%X.\n", basic_info.kernel_addr, diff --git a/src/kernel/include/kernel_log.hpp b/src/kernel/include/kernel_log.hpp index beb76bc8..8f66a619 100644 --- a/src/kernel/include/kernel_log.hpp +++ b/src/kernel/include/kernel_log.hpp @@ -36,7 +36,7 @@ static constexpr const auto kCyan = "\033[36m"; static constexpr const auto kWhite = "\033[37m"; template -class Logger : public std::ostream { +class Logger : public sk_std::ostream { public: Logger& operator<<(int8_t val) override { OutputFunction("%d", val); diff --git a/src/kernel/libcxx/include/cstring b/src/kernel/libcxx/include/cstring index 0a371aa3..e032d692 100644 --- a/src/kernel/libcxx/include/cstring +++ b/src/kernel/libcxx/include/cstring @@ -19,7 +19,7 @@ #include "string.h" -namespace std { +namespace sk_std { using ::memcmp; using ::memcpy; @@ -34,6 +34,6 @@ using ::strncmp; using ::strncpy; using ::strnlen; -}; // namespace std +}; // namespace sk_std #endif /* SIMPLEKERNEL_SRC_KERNEL_LIBCXX_INCLUDE_CSTRING_ */ diff --git a/src/kernel/libcxx/include/iostream b/src/kernel/libcxx/include/iostream index c8c87fc1..98177dbc 100644 --- a/src/kernel/libcxx/include/iostream +++ b/src/kernel/libcxx/include/iostream @@ -20,7 +20,7 @@ #include -namespace std { +namespace sk_std { class ostream { public: enum openmode : uint8_t { @@ -57,6 +57,6 @@ inline ostream& endl(ostream& os) { return os << "\n"; } [[maybe_unused]] static ostream cout; -}; // namespace std +}; // namespace sk_std #endif /* SIMPLEKERNEL_SRC_KERNEL_LIBCXX_INCLUDE_IOSTREAM_ */ diff --git a/src/kernel/libcxx/iostream.cpp b/src/kernel/libcxx/iostream.cpp index 50f051d7..755d3030 100644 --- a/src/kernel/libcxx/iostream.cpp +++ b/src/kernel/libcxx/iostream.cpp @@ -21,7 +21,7 @@ #include "cstdio" -namespace std { +namespace sk_std { ostream& ostream::operator<<(int8_t val) { printf("%d", val); @@ -72,4 +72,4 @@ ostream& ostream::operator<<(ostream& (*manip)(ostream&)) { return manip(*this); } -}; // namespace std +}; // namespace sk_std diff --git a/src/kernel/main.cpp b/src/kernel/main.cpp index a38f0d62..8b32b47c 100644 --- a/src/kernel/main.cpp +++ b/src/kernel/main.cpp @@ -49,7 +49,7 @@ uint32_t main(uint32_t argc, uint8_t *argv) { DumpStack(); - std::cout << "Hello ostream" << std::endl; + sk_std::cout << "Hello ostream" << sk_std::endl; return 0; }