Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/high_level.rs
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,8 @@ pub fn exec_cell(

/// Spawn a cell in cell dep.
///
/// Return the process id or a syscall error
///
/// # Arguments
///
/// * `code_hash` - the code hash to search cell in cell deps.
Expand Down
13 changes: 1 addition & 12 deletions src/syscalls/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -544,14 +544,13 @@ pub use crate::syscalls::internal::SpawnArgs;
/// The parent process calls the Spawn system call, which creates a new process (a child process) that is an
/// independent ckb-vm instance. It's important to note that the parent process will not be blocked by the child
/// process as a result of this syscall.
/// Note: available after ckb 2nd hardfork.
///
/// # Arguments
///
/// * `index`, `source`, `bounds` and `place` - same as exec.
/// * `spgs` - spawn arguments.
///
/// Returns success or a syscall error.
/// Return the process id or a syscall error
///
/// # Scheduler Algorithm V1
///
Expand Down Expand Up @@ -624,7 +623,6 @@ pub fn spawn(
}

/// The syscall pauses until the execution of a process specified by pid has ended.
/// Note: available after ckb 2nd hardfork.
///
/// # Arguments
///
Expand All @@ -642,14 +640,12 @@ pub fn wait(pid: u64) -> Result<i8, SysError> {
}

/// This syscall is used to get the current process id. Root process ID is 0.
/// Note: available after ckb 2nd hardfork.
pub fn process_id() -> u64 {
unsafe { syscall(0, 0, 0, 0, 0, 0, SYS_PROCESS_ID) }
}

/// This syscall create a pipe with read-write pair of file descriptions. The file descriptor with read permission is
/// located at fds[0], and the corresponding file descriptor with write permission is located at fds[1].
/// Note: available after ckb 2nd hardfork.
pub fn pipe() -> Result<(u64, u64), SysError> {
let mut fds: [u64; 2] = [0, 0];
let ret = unsafe { syscall(fds.as_mut_ptr() as u64, 0, 0, 0, 0, 0, SYS_PIPE) };
Expand All @@ -662,7 +658,6 @@ pub fn pipe() -> Result<(u64, u64), SysError> {

/// This syscall reads data from a pipe via a file descriptor. The syscall Read attempts to read up to value pointed by
/// length bytes from file descriptor fd into the buffer, and the actual length of data read is returned.
/// Note: available after ckb 2nd hardfork.
pub fn read(fd: u64, buffer: &mut [u8]) -> Result<usize, SysError> {
let mut l: u64 = buffer.len() as u64;
let ret = unsafe {
Expand Down Expand Up @@ -690,8 +685,6 @@ pub fn read(fd: u64, buffer: &mut [u8]) -> Result<usize, SysError> {
///
/// If buffer is empty and fd is avaliable, then write() can still succeed: A data with a length of 0 is written to the
/// pipe. The peer needs to use a read() syscall to consume the empty data, and read() will returns Ok(0).
///
/// Note: available after ckb 2nd hardfork.
pub fn write(fd: u64, buffer: &[u8]) -> Result<usize, SysError> {
let mut l: u64 = buffer.len() as u64;
let ret = unsafe {
Expand All @@ -716,7 +709,6 @@ pub fn write(fd: u64, buffer: &[u8]) -> Result<usize, SysError> {

/// This syscall retrieves the file descriptors available to the current process, which are passed in from the parent
/// process. These results are copied from the inherited_fds parameter of the Spawn syscall.
/// Note: available after ckb 2nd hardfork.
pub fn inherited_fds(fds: &mut [u64]) -> u64 {
let mut l: u64 = fds.len() as u64;
unsafe {
Expand All @@ -735,7 +727,6 @@ pub fn inherited_fds(fds: &mut [u64]) -> u64 {

/// This syscall manually closes a file descriptor. After calling this, any attempt to read/write the file descriptor
/// pointed to the other end would fail.
/// Note: available after ckb 2nd hardfork.
pub fn close(fd: u64) -> Result<(), SysError> {
let ret = unsafe { syscall(fd, 0, 0, 0, 0, 0, SYS_CLOSE) };
match ret {
Expand All @@ -754,8 +745,6 @@ pub fn close(fd: u64) -> Result<(), SysError> {
/// * `offset` - offset
/// * `index` - index of cell
/// * `source` - source of cell
///
/// Note: available after ckb 2nd hardfork.
pub fn load_block_extension(
buf: &mut [u8],
offset: usize,
Expand Down