From 70b6db4282d7d74b1cb1c0dfecf7691fc2692133 Mon Sep 17 00:00:00 2001 From: WangRunji Date: Sun, 23 Dec 2018 03:10:59 +0800 Subject: [PATCH] make clear_bss faster --- kernel/src/arch/riscv32/memory.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/kernel/src/arch/riscv32/memory.rs b/kernel/src/arch/riscv32/memory.rs index 2ae895b3..3c6c481b 100644 --- a/kernel/src/arch/riscv32/memory.rs +++ b/kernel/src/arch/riscv32/memory.rs @@ -86,10 +86,11 @@ fn remap_the_kernel() { static mut SATP: usize = 0; pub unsafe fn clear_bss() { - let bss_start = sbss as usize; - let bss_end = ebss as usize; - for i in bss_start..bss_end { - (i as *mut u8).write(0); + let start = sbss as usize; + let end = ebss as usize; + let step = core::mem::size_of::(); + for i in (start..end).step_by(step) { + (i as *mut usize).write(0); } }