Skip to content

Commit 42c1eaa

Browse files
committed
feat: move link vars to basic_info
Signed-off-by: Zone.N <[email protected]>
1 parent 07e74d1 commit 42c1eaa

File tree

4 files changed

+33
-40
lines changed

4 files changed

+33
-40
lines changed

.pre-commit-config.yaml

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,30 +22,30 @@ repos:
2222
- id: clang-format
2323
args:
2424
- --style=file
25-
- id: clang-tidy
26-
args:
27-
- --checks=.clang-tidy
28-
- -p=/root/SimpleKernel/build_x86_64/compiler_commands.json
29-
- -extra-arg=--std=c++2b
30-
- --fix
31-
- --header-filter=^(/root/SimpleKernel/build_x86_64/src/).*
32-
# - --exclude-header-filter=^(?/root/SimpleKernel/build_x86_64/src/arch/x86_64|/root/SimpleKernel/build_x86_64/src/arch/aarch64).*
3325
# - id: clang-tidy
3426
# args:
3527
# - --checks=.clang-tidy
36-
# - -p=/root/SimpleKernel/build_x86_64/build_x86_64/compiler_commands.json
28+
# - -p=/root/SimpleKernel/build_aarch64/compiler_commands.json
29+
# - -extra-arg=--std=c++2b
30+
# - --fix
31+
# - --header-filter=^(/root/SimpleKernel/build_aarch64/src/).*
32+
# - --exclude-header-filter=^(?/root/SimpleKernel/build_aarch64/src/arch/x86_64|/root/SimpleKernel/build_aarch64/src/arch/aarch64).*
33+
# - id: clang-tidy
34+
# args:
35+
# - --checks=.clang-tidy
36+
# - -p=/root/SimpleKernel/build_aarch64/build_x86_64/compiler_commands.json
3737
# - -extra-arg=--std=c++2b
3838
# - --fix
39-
# - --header-filter=^(?/root/SimpleKernel/build_x86_64/src/).*
40-
# - --exclude-header-filter=^(?/root/SimpleKernel/build_x86_64/src/arch/riscv_64|/root/SimpleKernel/build_x86_64/src/arch/aarch64).*
39+
# - --header-filter=^(?/root/SimpleKernel/build_aarch64/src/).*
40+
# - --exclude-header-filter=^(?/root/SimpleKernel/build_aarch64/src/arch/riscv_64|/root/SimpleKernel/build_aarch64/src/arch/aarch64).*
4141
# - id: clang-tidy
4242
# args:
4343
# - --checks=.clang-tidy
44-
# - -p=/root/SimpleKernel/build_x86_64/build_aarch64/compiler_commands.json
44+
# - -p=/root/SimpleKernel/build_aarch64/build_aarch64/compiler_commands.json
4545
# - -extra-arg=--std=c++2b
4646
# - --fix
47-
# - --header-filter=^(?/root/SimpleKernel/build_x86_64/src/).*
48-
# - --exclude-header-filter=^(?/root/SimpleKernel/build_x86_64/src/arch/riscv64|/root/SimpleKernel/build_x86_64/src/arch/x86_64).*
47+
# - --header-filter=^(?/root/SimpleKernel/build_aarch64/src/).*
48+
# - --exclude-header-filter=^(?/root/SimpleKernel/build_aarch64/src/arch/riscv64|/root/SimpleKernel/build_aarch64/src/arch/x86_64).*
4949

5050
- repo: https://github.com/koalaman/shellcheck-precommit
5151
rev: v0.10.0

src/kernel/arch/aarch64/arch_main.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,9 @@ auto ArchInit(uint32_t argc, const uint8_t* argv) -> uint32_t {
3434

3535
return 0;
3636
}
37+
38+
auto ArchInitSMP(uint32_t argc, const uint8_t* argv) -> uint32_t {
39+
(void)argc;
40+
(void)argv;
41+
return 0;
42+
}

src/kernel/libcxx/sk_libcxx.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ extern "C" function_t __fini_array_start;
3030
/// 全局析构函数函数指针终点地址
3131
extern "C" function_t __fini_array_end;
3232
/// 动态共享对象标识,内核使用静态链接,此变量在内核中没有使用
33-
void* dso_handle = nullptr;
33+
void* __dso_handle = nullptr;
3434

3535
/// 最大析构函数数量
3636
static constexpr const size_t kMaxAtExitFuncsCount = 128;
@@ -170,12 +170,12 @@ extern "C" void __cxa_rethrow() {
170170
;
171171
}
172172
}
173-
extern "C" void Unwind_Resume() {
173+
extern "C" void _Unwind_Resume() {
174174
while (true) {
175175
;
176176
}
177177
}
178-
extern "C" void _gxx_personality_v0() {
178+
extern "C" void __gxx_personality_v0() {
179179
while (true) {
180180
;
181181
}

test/unit_test/spinlock_test.cpp

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,13 @@
1919
#include <gmock/gmock.h>
2020
#include <gtest/gtest.h>
2121

22+
#include <array>
2223
#include <format>
2324
#include <thread>
2425
#include <vector>
2526

27+
// static std::array<PerCpu, PerCpu::kMaxCoreCount> g_per_cpu{};
28+
2629
class TestableSpinLock : public SpinLock {
2730
public:
2831
using SpinLock::SpinLock;
@@ -32,10 +35,10 @@ class TestableSpinLock : public SpinLock {
3235
using SpinLock::IsLockedByCurrentCore;
3336
using SpinLock::RestoreInterruptsNested;
3437

35-
void intr_on() const override {}
36-
void intr_off() const override {}
37-
auto intr_status() const -> bool override { return false; }
38-
auto core_id() const -> size_t override {
38+
void EnableInterrupt() const override {}
39+
void DisableInterrupt() const override {}
40+
auto GetInterruptStatus() const -> bool override { return false; }
41+
auto GetCurrentCoreId() const -> size_t override {
3942
return std::hash<std::thread::id>{}(std::this_thread::get_id());
4043
}
4144
};
@@ -56,44 +59,28 @@ TEST_F(TestableSpinLockTest, LockUnlockTest) {
5659
}
5760

5861
TEST_F(TestableSpinLockTest, MultiThreadLockUnlockTest) {
59-
auto thread_func = [this](const std::string& name) {
62+
auto thread_func = [this]() {
6063
spinlock.lock();
6164
EXPECT_TRUE(spinlock.IsLockedByCurrentCore());
62-
63-
std::this_thread::sleep_for(std::chrono::milliseconds(500));
64-
spinlock.unlock();
65-
EXPECT_FALSE(spinlock.IsLockedByCurrentCore());
66-
67-
spinlock.lock();
68-
EXPECT_TRUE(spinlock.IsLockedByCurrentCore());
69-
7065
std::this_thread::sleep_for(std::chrono::milliseconds(500));
7166
spinlock.unlock();
7267
EXPECT_FALSE(spinlock.IsLockedByCurrentCore());
7368

7469
spinlock.lock();
7570
EXPECT_TRUE(spinlock.IsLockedByCurrentCore());
76-
77-
std::this_thread::sleep_for(std::chrono::milliseconds(500));
78-
spinlock.unlock();
79-
EXPECT_FALSE(spinlock.IsLockedByCurrentCore());
80-
81-
spinlock.lock();
82-
EXPECT_TRUE(spinlock.IsLockedByCurrentCore());
83-
8471
std::this_thread::sleep_for(std::chrono::milliseconds(500));
8572
spinlock.unlock();
8673
EXPECT_FALSE(spinlock.IsLockedByCurrentCore());
8774
};
8875

8976
std::vector<std::thread> threads;
9077
for (int i = 0; i < 100; ++i) {
91-
threads.emplace_back(thread_func, "thread" + std::to_string(i + 1));
78+
threads.emplace_back(thread_func);
9279
}
9380

9481
for (auto& thread : threads) {
9582
thread.detach();
9683
}
9784

98-
std::this_thread::sleep_for(std::chrono::seconds(8));
85+
std::this_thread::sleep_for(std::chrono::seconds(2));
9986
}

0 commit comments

Comments
 (0)