Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjusting the spawn syscall #63

Merged
merged 2 commits into from
Sep 11, 2024
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: 1 addition & 1 deletion ckb_consts.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#define SYS_ckb_pipe 2604
#define SYS_ckb_write 2605
#define SYS_ckb_read 2606
#define SYS_ckb_inherited_fd 2607
#define SYS_ckb_inherited_fds 2607
#define SYS_ckb_close 2608

#define CKB_SUCCESS 0
Expand Down
9 changes: 8 additions & 1 deletion ckb_syscall_apis.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ typedef struct spawn_args_t {

int ckb_spawn(size_t index, size_t source, size_t place, size_t bounds,
spawn_args_t* spawn_args);

int ckb_spawn_cell(const uint8_t* code_hash, uint8_t hash_type, uint32_t offset,
uint32_t length, spawn_args_t* spawn_args);

int ckb_wait(uint64_t pid, int8_t* exit_code);

uint64_t ckb_process_id();
Expand All @@ -63,8 +67,11 @@ int ckb_read(uint64_t fd, void* buffer, size_t* length);

int ckb_write(uint64_t fd, const void* buffer, size_t* length);

int ckb_inherited_file_descriptors(uint64_t* fd, size_t* length);
int ckb_inherited_fds(uint64_t* fds, size_t* length);

int ckb_close(uint64_t fd);

int ckb_load_block_extension(void* addr, uint64_t* len, size_t offset,
size_t index, size_t source);

#endif /* CKB_C_STDLIB_CKB_SYSCALL_APIS_H_ */
16 changes: 14 additions & 2 deletions ckb_syscalls.h
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,18 @@ int ckb_spawn(size_t index, size_t source, size_t place, size_t bounds,
return syscall(SYS_ckb_spawn, index, source, place, bounds, spawn_args, 0);
}

int ckb_spawn_cell(const uint8_t* code_hash, uint8_t hash_type, uint32_t offset,
uint32_t length, spawn_args_t* spawn_args) {
size_t index = SIZE_MAX;
int ret = ckb_look_for_dep_with_hash2(code_hash, hash_type, &index);
if (ret != CKB_SUCCESS) {
return ret;
}
size_t bounds = ((size_t)offset << 32) | length;
return syscall(SYS_ckb_spawn, index, CKB_SOURCE_CELL_DEP, 0, bounds,
spawn_args, 0);
}

int ckb_wait(uint64_t pid, int8_t* exit_code) {
return syscall(SYS_ckb_wait, pid, exit_code, 0, 0, 0, 0);
}
Expand Down Expand Up @@ -414,9 +426,9 @@ int ckb_load_block_extension(void* addr, uint64_t* len, size_t offset,
0);
}

int ckb_inherited_file_descriptors(uint64_t* fd, size_t* length) {
int ckb_inherited_fds(uint64_t* fds, size_t* length) {
volatile size_t l = *length;
int ret = syscall(SYS_ckb_inherited_fd, fd, &l, 0, 0, 0, 0);
int ret = syscall(SYS_ckb_inherited_fds, fds, &l, 0, 0, 0, 0);
*length = l;
return ret;
}
Expand Down