1
0
mirror of https://github.com/rcore-os/rCore.git synced 2025-01-18 17:07:04 +04:00

Remove non snake case names

This commit is contained in:
Jiajie Chen 2020-06-30 12:59:17 +08:00
parent 427a338095
commit 21f024c76d
4 changed files with 26 additions and 22 deletions

View File

@ -86,13 +86,13 @@ impl Drop for SemProc {
impl ShmProc {
/// Insert the `SharedGuard` and return its ID
pub fn add(&mut self, sharedGuard: Arc<spin::Mutex<SharedGuard<GlobalFrameAlloc>>>) -> ShmId {
pub fn add(&mut self, shared_guard: Arc<spin::Mutex<SharedGuard<GlobalFrameAlloc>>>) -> ShmId {
let id = self.get_free_id();
let shmIdentifier = ShmIdentifier {
let shm_identifier = ShmIdentifier {
addr: 0,
sharedGuard: sharedGuard,
shared_guard: shared_guard,
};
self.shm_identifiers.insert(id, shmIdentifier);
self.shm_identifiers.insert(id, shm_identifier);
id
}
/// Get a free ID
@ -105,12 +105,14 @@ impl ShmProc {
pub fn get(&self, id: ShmId) -> Option<ShmIdentifier> {
self.shm_identifiers.get(&id).map(|a| a.clone())
}
/// Used to set Virtual Addr
pub fn set(&mut self, id: ShmId, shmId: ShmIdentifier) {
self.shm_identifiers.insert(id, shmId);
pub fn set(&mut self, id: ShmId, shm_id: ShmIdentifier) {
self.shm_identifiers.insert(id, shm_id);
}
/// get id from virtaddr
pub fn getId(&self, addr: VirtAddr) -> Option<ShmId> {
pub fn get_id(&self, addr: VirtAddr) -> Option<ShmId> {
for (key, value) in &self.shm_identifiers {
if value.addr == addr {
return Some(*key);

View File

@ -16,14 +16,15 @@ lazy_static! {
#[derive(Clone)]
pub struct ShmIdentifier {
pub addr: VirtAddr,
pub sharedGuard: Arc<spin::Mutex<SharedGuard<GlobalFrameAlloc>>>,
pub shared_guard: Arc<spin::Mutex<SharedGuard<GlobalFrameAlloc>>>,
}
impl ShmIdentifier {
pub fn setAddr(&mut self, addr: VirtAddr) {
pub fn set_addr(&mut self, addr: VirtAddr) {
self.addr = addr;
}
pub fn new_sharedGuard(
pub fn new_shared_guard(
key: usize,
memsize: usize,
) -> Arc<spin::Mutex<SharedGuard<GlobalFrameAlloc>>> {
@ -35,12 +36,12 @@ impl ShmIdentifier {
return guard;
}
}
let mut sharedGuard = Arc::new(spin::Mutex::new(SharedGuard::new_with_size(
let mut shared_guard = Arc::new(spin::Mutex::new(SharedGuard::new_with_size(
GlobalFrameAlloc,
memsize,
)));
// insert to global map
key2shm.insert(key, Arc::downgrade(&sharedGuard));
sharedGuard
key2shm.insert(key, Arc::downgrade(&shared_guard));
shared_guard
}
}

View File

@ -14,6 +14,7 @@
#![deny(unused_unsafe)]
#![deny(ellipsis_inclusive_range_patterns)]
#![deny(unused_parens)]
#![deny(non_snake_case)]
#![allow(non_upper_case_globals)]
#![allow(dead_code)]
#![allow(unused_mut)]

View File

@ -105,13 +105,13 @@ impl Syscall<'_> {
pub fn sys_shmget(&self, key: usize, size: usize, shmflg: usize) -> SysResult {
info!("shmget: key: {}", key);
let sharedGuard = ShmIdentifier::new_sharedGuard(key, size);
let id = self.process().shm_identifiers.add(sharedGuard);
let shared_guard = ShmIdentifier::new_shared_guard(key, size);
let id = self.process().shm_identifiers.add(shared_guard);
Ok(id)
}
pub fn sys_shmat(&self, id: usize, mut addr: VirtAddr, shmflg: usize) -> SysResult {
let mut shmIdentifier = self
let mut shm_identifier = self
.process()
.shm_identifiers
.get(id)
@ -124,18 +124,18 @@ impl Syscall<'_> {
// so just skip it
addr = PAGE_SIZE;
}
let size = shmIdentifier.sharedGuard.lock().size;
let size = shm_identifier.shared_guard.lock().size;
info!("shmat: id: {}, addr = {:#x}, size = {}", id, addr, size);
addr = self.vm().find_free_area(addr, size);
self.vm().push(
addr,
addr + size,
MemoryAttr::default().user().execute().writable(),
Shared::new_with_guard(GlobalFrameAlloc, shmIdentifier.sharedGuard.clone()),
Shared::new_with_guard(GlobalFrameAlloc, shm_identifier.shared_guard.clone()),
"shmat",
);
shmIdentifier.addr = addr;
proc.shm_identifiers.set(id, shmIdentifier);
shm_identifier.addr = addr;
proc.shm_identifiers.set(id, shm_identifier);
//self.process().shmIdentifiers.setVirtAddr(id, addr);
return Ok(addr);
}
@ -143,8 +143,8 @@ impl Syscall<'_> {
pub fn sys_shmdt(&self, id: usize, addr: VirtAddr, shmflg: usize) -> SysResult {
info!("shmdt: addr={:#x}", addr);
let mut proc = self.process();
let optId = proc.shm_identifiers.getId(addr);
if let Some(id) = optId {
let opt_id = proc.shm_identifiers.get_id(addr);
if let Some(id) = opt_id {
proc.shm_identifiers.pop(id);
}
Ok(0)