Skip to content

Commit

Permalink
refactor: rename std::ostream with sk_std::
Browse files Browse the repository at this point in the history
Signed-off-by: Zone.N <[email protected]>
  • Loading branch information
MRNIU committed Aug 7, 2024
1 parent 58bb3db commit 071768e
Show file tree
Hide file tree
Showing 11 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/kernel/arch/aarch64/include/cpu.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ class ReadWriteRegBase : public ReadOnlyRegBase<RegInfo>,
// 第三部分:寄存器实例
class X29 : public ReadWriteRegBase<reginfo::X29Info> {
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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/kernel/arch/riscv64/arch_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/kernel/arch/riscv64/include/cpu.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ class ReadWriteRegBase : public ReadOnlyRegBase<RegInfo>,
// 第三部分:寄存器实例
class Fp : public ReadWriteRegBase<reginfo::FpInfo> {
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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/kernel/arch/x86_64/arch_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/kernel/arch/x86_64/include/cpu.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ class ReadWriteRegBase : public ReadOnlyRegBase<RegInfo>,
// 第三部分:寄存器实例
class Rbp : public ReadWriteRegBase<reginfo::RbpInfo> {
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;
}
Expand Down
4 changes: 2 additions & 2 deletions src/kernel/include/basic_info.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/kernel/include/kernel_log.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ static constexpr const auto kCyan = "\033[36m";
static constexpr const auto kWhite = "\033[37m";

template <void (*OutputFunction)(const char* format, ...)>
class Logger : public std::ostream {
class Logger : public sk_std::ostream {
public:
Logger& operator<<(int8_t val) override {
OutputFunction("%d", val);
Expand Down
4 changes: 2 additions & 2 deletions src/kernel/libcxx/include/cstring
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

#include "string.h"

namespace std {
namespace sk_std {

using ::memcmp;
using ::memcpy;
Expand All @@ -34,6 +34,6 @@ using ::strncmp;
using ::strncpy;
using ::strnlen;

}; // namespace std
}; // namespace sk_std

#endif /* SIMPLEKERNEL_SRC_KERNEL_LIBCXX_INCLUDE_CSTRING_ */
4 changes: 2 additions & 2 deletions src/kernel/libcxx/include/iostream
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

#include <cstdint>

namespace std {
namespace sk_std {
class ostream {
public:
enum openmode : uint8_t {
Expand Down Expand Up @@ -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_ */
4 changes: 2 additions & 2 deletions src/kernel/libcxx/iostream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

#include "cstdio"

namespace std {
namespace sk_std {

ostream& ostream::operator<<(int8_t val) {
printf("%d", val);
Expand Down Expand Up @@ -72,4 +72,4 @@ ostream& ostream::operator<<(ostream& (*manip)(ostream&)) {
return manip(*this);
}

}; // namespace std
}; // namespace sk_std
2 changes: 1 addition & 1 deletion src/kernel/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

0 comments on commit 071768e

Please sign in to comment.