Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into thread_local_storage
Browse files Browse the repository at this point in the history
  • Loading branch information
Orycterope committed Jul 31, 2019
2 parents 8157c2f + 03b6029 commit e131d84
Show file tree
Hide file tree
Showing 11 changed files with 249 additions and 413 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ deploy:
branch: master
condition: -z "${NO_TESTS_NO_DEPLOY}"

cache: cargo
# See issue #378
cache: false
before_cache:
# Travis can't cache files that are not readable by "others"
- chmod -R a+r $HOME/.cargo
17 changes: 16 additions & 1 deletion kernel/src/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@ pub enum Handle {
ClientSession(ClientSession),
/// A thread.
Thread(Weak<ThreadStruct>),
/// A process.
Process(Arc<ProcessStruct>),
/// A shared memory region. The handle holds on to the underlying physical
/// memory, which means the memory will only get freed once all handles to
/// it are dropped.
Expand Down Expand Up @@ -217,6 +219,15 @@ impl Handle {
}
}

/// Casts the handle as an Arc<[ProcessStruct]>, or returns a `UserspaceError`.
pub fn as_process(&self) -> Result<Arc<ProcessStruct>, UserspaceError> {
if let Handle::Process(ref s) = *self {
Ok((*s).clone())
} else {
Err(UserspaceError::InvalidHandle)
}
}

/// Casts the handle as an Arc<RwLock<Vec<[PhysicalMemRegion]>>>, or returns a
/// `UserspaceError`.
pub fn as_shared_memory(&self) -> Result<Arc<RwLock<Vec<PhysicalMemRegion>>>, UserspaceError> {
Expand Down Expand Up @@ -294,7 +305,11 @@ impl HandleTable {

/// Gets the Kernel Handle associated with the given userspace handle number.
pub fn get_handle(&self, handle: u32) -> Result<Arc<Handle>, UserspaceError> {
self.table.get(&handle).cloned().ok_or(UserspaceError::InvalidHandle)
match handle {
0xFFFF8000 => Ok(Arc::new(Handle::Thread(Arc::downgrade(&scheduler::get_current_thread())))),
0xFFFF8001 => Ok(Arc::new(Handle::Process(scheduler::get_current_process()))),
handle => self.table.get(&handle).cloned().ok_or(UserspaceError::InvalidHandle)
}
}

/// Deletes the mapping from the given userspace handle number. Returns the
Expand Down
336 changes: 0 additions & 336 deletions libuser/src/ipc/buffer.rs

This file was deleted.

Loading

0 comments on commit e131d84

Please sign in to comment.