Skip to content

Commit e75bcf6

Browse files
committed
修复小bug、注释
1 parent d39848b commit e75bcf6

File tree

31 files changed

+247
-438
lines changed

31 files changed

+247
-438
lines changed

machines/qemu-virt-riscv64/rust/core/src/api/libloading.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ impl Library {
148148
let h = self.handle;
149149
forget(self);
150150
let rc = libc::dlclose(h);
151-
if rc != 0 {
151+
if rc == 1 {
152152
Ok(())
153153
} else {
154154
Err(DlError::Close(rc))

machines/qemu-virt-riscv64/rust/core/src/api/mod.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
/*
2+
* Copyright (c) 2006-2024, RT-Thread Development Team
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*
6+
* Change Logs:
7+
* Date Author notes
8+
* 2025-10-10 foxglove API module
9+
*/
110
pub mod base;
211
pub mod interrupt;
312
pub mod mem;
Lines changed: 75 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,78 @@
1+
/*
2+
* Copyright (c) 2006-2024, RT-Thread Development Team
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*
6+
* Change Logs:
7+
* Date Author notes
8+
* 2025-10-10 foxglove Bindings module
9+
*/
110
pub mod libc;
211
pub mod librt;
312

4-
pub use librt::*;
13+
// Explicitly re-export only the needed items from librt to avoid namespace pollution.
14+
// Basic RT-Thread types
15+
pub use librt::{
16+
rt_base_t, rt_ubase_t, rt_err_t, rt_uint32_t, rt_int32_t, rt_uint8_t,
17+
rt_tick_t, rt_size_t, rt_thread_t, rt_sem_t, rt_mutex_t, rt_device_t, rt_mq_t
18+
};
19+
20+
// RT-Thread error codes
21+
pub use librt::{
22+
RT_EOK, RT_ERROR, RT_ETIMEOUT, RT_EFULL, RT_EEMPTY, RT_ENOMEM,
23+
RT_ENOSYS, RT_EBUSY, RT_EIO, RT_EINTR, RT_EINVAL
24+
};
25+
26+
// Thread management functions
27+
pub use librt::{
28+
rt_thread_create, rt_thread_delete, rt_thread_startup, rt_thread_self,
29+
rt_thread_yield, rt_thread_delay, rt_thread_mdelay, rt_thread_suspend, rt_thread_resume
30+
};
31+
32+
// Semaphore management functions
33+
pub use librt::{
34+
rt_sem_create, rt_sem_delete, rt_sem_take, rt_sem_trytake, rt_sem_release
35+
};
36+
37+
// Mutex management functions
38+
pub use librt::{
39+
rt_mutex_create, rt_mutex_delete, rt_mutex_take, rt_mutex_release
40+
};
41+
42+
// Message queue management functions
43+
pub use librt::{
44+
rt_mq_create, rt_mq_send, rt_mq_send_wait, rt_mq_recv, rt_mq_delete, rt_mq_detach
45+
};
46+
47+
// Memory management functions
48+
pub use librt::{
49+
rt_malloc, rt_free, rt_realloc, rt_calloc, rt_malloc_align, rt_free_align,
50+
rt_safe_malloc, rt_safe_free
51+
};
52+
53+
// Device management functions
54+
pub use librt::{
55+
rt_device_find, rt_device_open, rt_device_close, rt_device_read,
56+
rt_device_write, rt_device_control
57+
};
58+
59+
// System tick functions
60+
pub use librt::{
61+
rt_tick_get, rt_tick_from_millisecond
62+
};
63+
64+
// Debug output functions
65+
pub use librt::{
66+
rt_kprintf, rt_kputs
67+
};
68+
69+
// Interrupt management functions
70+
pub use librt::{
71+
rt_hw_interrupt_disable, rt_hw_interrupt_enable, rt_cpus_lock, rt_cpus_unlock,
72+
rt_interrupt_enter, rt_interrupt_leave, rt_interrupt_get_nest
73+
};
74+
75+
// Object management functions
76+
pub use librt::{
77+
rt_object_get_type, rt_object_find
78+
};

machines/qemu-virt-riscv64/rust/core/src/libloader.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ pub unsafe fn dl_sym<'lib, T>(lib: &'lib Library, symbol: *const c_char) -> Resu
4343

4444
/// Print the last libdl error using RT-Thread `printf`.
4545
pub fn dl_print_last_error() {
46-
// 使用 println! 更符合当前输出宏
4746
println!("libdl error: {}", libloading::DlError::Open(last_error()));
4847
}
4948

machines/qemu-virt-riscv64/rust/core/src/panic.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,5 +58,8 @@ fn panic(info: &core::panic::PanicInfo) -> ! {
5858
#[linkage = "weak"]
5959
#[unsafe(no_mangle)]
6060
fn __rust_panic() -> ! {
61+
// Default weak panic handler: intentionally loops forever to halt execution.
62+
// Override this function for custom panic behavior.
63+
print!("Entered weak panic handler: system will halt.");
6164
loop {}
6265
}

machines/qemu-virt-riscv64/rust/core/src/param.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
/*
2+
* Copyright (c) 2006-2024, RT-Thread Development Team
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*
6+
* Change Logs:
7+
* Date Author notes
8+
* 2025-10-10 foxglove Parameter module
9+
*/
10+
111
use alloc::vec::Vec;
212
use core::iter::IntoIterator;
313
use core::ops::Deref;
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,11 @@
1+
/*
2+
* Copyright (c) 2006-2024, RT-Thread Development Team
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*
6+
* Change Logs:
7+
* Date Author notes
8+
* 2025-10-10 foxglove Prelude module
9+
*/
110
#[path = "no_std.rs"]
211
pub mod v1;

machines/qemu-virt-riscv64/rust/core/src/prelude/no_std.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
/*
2+
* Copyright (c) 2006-2024, RT-Thread Development Team
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*
6+
* Change Logs:
7+
* Date Author notes
8+
* 2025-10-10 foxglove Prelude module
9+
*/
110
pub use core::cell::RefCell;
211
pub use core::cell::UnsafeCell;
312
pub use core::cmp::*;

machines/qemu-virt-riscv64/rust/core/src/sem.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,9 @@ impl Semaphore {
7272
pub fn release(&self) {
7373
semaphore_release(self.sem);
7474
}
75+
}
7576

77+
impl Drop for Semaphore {
7678
fn drop(&mut self) {
7779
semaphore_delete(self.sem)
7880
}
File renamed without changes.

0 commit comments

Comments
 (0)