Skip to content

Commit

Permalink
feat: move link vars to basic_info
Browse files Browse the repository at this point in the history
Signed-off-by: Zone.N <[email protected]>
  • Loading branch information
MRNIU committed Jan 7, 2025
1 parent 07e74d1 commit 42c1eaa
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 40 deletions.
28 changes: 14 additions & 14 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,30 +22,30 @@ repos:
- id: clang-format
args:
- --style=file
- id: clang-tidy
args:
- --checks=.clang-tidy
- -p=/root/SimpleKernel/build_x86_64/compiler_commands.json
- -extra-arg=--std=c++2b
- --fix
- --header-filter=^(/root/SimpleKernel/build_x86_64/src/).*
# - --exclude-header-filter=^(?/root/SimpleKernel/build_x86_64/src/arch/x86_64|/root/SimpleKernel/build_x86_64/src/arch/aarch64).*
# - id: clang-tidy
# args:
# - --checks=.clang-tidy
# - -p=/root/SimpleKernel/build_x86_64/build_x86_64/compiler_commands.json
# - -p=/root/SimpleKernel/build_aarch64/compiler_commands.json
# - -extra-arg=--std=c++2b
# - --fix
# - --header-filter=^(/root/SimpleKernel/build_aarch64/src/).*
# - --exclude-header-filter=^(?/root/SimpleKernel/build_aarch64/src/arch/x86_64|/root/SimpleKernel/build_aarch64/src/arch/aarch64).*
# - id: clang-tidy
# args:
# - --checks=.clang-tidy
# - -p=/root/SimpleKernel/build_aarch64/build_x86_64/compiler_commands.json
# - -extra-arg=--std=c++2b
# - --fix
# - --header-filter=^(?/root/SimpleKernel/build_x86_64/src/).*
# - --exclude-header-filter=^(?/root/SimpleKernel/build_x86_64/src/arch/riscv_64|/root/SimpleKernel/build_x86_64/src/arch/aarch64).*
# - --header-filter=^(?/root/SimpleKernel/build_aarch64/src/).*
# - --exclude-header-filter=^(?/root/SimpleKernel/build_aarch64/src/arch/riscv_64|/root/SimpleKernel/build_aarch64/src/arch/aarch64).*
# - id: clang-tidy
# args:
# - --checks=.clang-tidy
# - -p=/root/SimpleKernel/build_x86_64/build_aarch64/compiler_commands.json
# - -p=/root/SimpleKernel/build_aarch64/build_aarch64/compiler_commands.json
# - -extra-arg=--std=c++2b
# - --fix
# - --header-filter=^(?/root/SimpleKernel/build_x86_64/src/).*
# - --exclude-header-filter=^(?/root/SimpleKernel/build_x86_64/src/arch/riscv64|/root/SimpleKernel/build_x86_64/src/arch/x86_64).*
# - --header-filter=^(?/root/SimpleKernel/build_aarch64/src/).*
# - --exclude-header-filter=^(?/root/SimpleKernel/build_aarch64/src/arch/riscv64|/root/SimpleKernel/build_aarch64/src/arch/x86_64).*

- repo: https://github.com/koalaman/shellcheck-precommit
rev: v0.10.0
Expand Down
6 changes: 6 additions & 0 deletions src/kernel/arch/aarch64/arch_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,9 @@ auto ArchInit(uint32_t argc, const uint8_t* argv) -> uint32_t {

return 0;
}

auto ArchInitSMP(uint32_t argc, const uint8_t* argv) -> uint32_t {
(void)argc;
(void)argv;
return 0;
}
6 changes: 3 additions & 3 deletions src/kernel/libcxx/sk_libcxx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ extern "C" function_t __fini_array_start;
/// 全局析构函数函数指针终点地址
extern "C" function_t __fini_array_end;
/// 动态共享对象标识,内核使用静态链接,此变量在内核中没有使用
void* dso_handle = nullptr;
void* __dso_handle = nullptr;

/// 最大析构函数数量
static constexpr const size_t kMaxAtExitFuncsCount = 128;
Expand Down Expand Up @@ -170,12 +170,12 @@ extern "C" void __cxa_rethrow() {
;
}
}
extern "C" void Unwind_Resume() {
extern "C" void _Unwind_Resume() {
while (true) {
;
}
}
extern "C" void _gxx_personality_v0() {
extern "C" void __gxx_personality_v0() {
while (true) {
;
}
Expand Down
33 changes: 10 additions & 23 deletions test/unit_test/spinlock_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,13 @@
#include <gmock/gmock.h>
#include <gtest/gtest.h>

#include <array>
#include <format>
#include <thread>
#include <vector>

// static std::array<PerCpu, PerCpu::kMaxCoreCount> g_per_cpu{};

class TestableSpinLock : public SpinLock {
public:
using SpinLock::SpinLock;
Expand All @@ -32,10 +35,10 @@ class TestableSpinLock : public SpinLock {
using SpinLock::IsLockedByCurrentCore;
using SpinLock::RestoreInterruptsNested;

void intr_on() const override {}
void intr_off() const override {}
auto intr_status() const -> bool override { return false; }
auto core_id() const -> size_t override {
void EnableInterrupt() const override {}
void DisableInterrupt() const override {}
auto GetInterruptStatus() const -> bool override { return false; }
auto GetCurrentCoreId() const -> size_t override {
return std::hash<std::thread::id>{}(std::this_thread::get_id());
}
};
Expand All @@ -56,44 +59,28 @@ TEST_F(TestableSpinLockTest, LockUnlockTest) {
}

TEST_F(TestableSpinLockTest, MultiThreadLockUnlockTest) {
auto thread_func = [this](const std::string& name) {
auto thread_func = [this]() {
spinlock.lock();
EXPECT_TRUE(spinlock.IsLockedByCurrentCore());

std::this_thread::sleep_for(std::chrono::milliseconds(500));
spinlock.unlock();
EXPECT_FALSE(spinlock.IsLockedByCurrentCore());

spinlock.lock();
EXPECT_TRUE(spinlock.IsLockedByCurrentCore());

std::this_thread::sleep_for(std::chrono::milliseconds(500));
spinlock.unlock();
EXPECT_FALSE(spinlock.IsLockedByCurrentCore());

spinlock.lock();
EXPECT_TRUE(spinlock.IsLockedByCurrentCore());

std::this_thread::sleep_for(std::chrono::milliseconds(500));
spinlock.unlock();
EXPECT_FALSE(spinlock.IsLockedByCurrentCore());

spinlock.lock();
EXPECT_TRUE(spinlock.IsLockedByCurrentCore());

std::this_thread::sleep_for(std::chrono::milliseconds(500));
spinlock.unlock();
EXPECT_FALSE(spinlock.IsLockedByCurrentCore());
};

std::vector<std::thread> threads;
for (int i = 0; i < 100; ++i) {
threads.emplace_back(thread_func, "thread" + std::to_string(i + 1));
threads.emplace_back(thread_func);
}

for (auto& thread : threads) {
thread.detach();
}

std::this_thread::sleep_for(std::chrono::seconds(8));
std::this_thread::sleep_for(std::chrono::seconds(2));
}

0 comments on commit 42c1eaa

Please sign in to comment.