Skip to content

Commit

Permalink
SDK implementation for newly added IO syscalls.
Browse files Browse the repository at this point in the history
  • Loading branch information
nthnn committed Mar 2, 2024
1 parent afab928 commit 6e8c2ed
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
10 changes: 10 additions & 0 deletions sdk/librishka/io.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@ class IO final {
static void print(i64 number);
static void print(double number);

static i32 read();
static i32 available();
static i32 peek();

static bool find(string target, usize size);
static bool find_until(string target, string terminator);

static void set_timeout(u64 timeout);
static u64 get_timeout();

static rune readch();
static string readline();
};
Expand Down
28 changes: 28 additions & 0 deletions sdk/librishka_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,34 @@ string IO::readline() {
return get_rt_string((u32) rishka_sc_0(RISHKA_SC_IO_READLINE));
}

i32 IO::read() {
return (i32) rishka_sc_0(RISHKA_SC_IO_READ);
}

i32 IO::available() {
return (i32) rishka_sc_0(RISHKA_SC_IO_AVAILABLE);
}

i32 IO::peek() {
return (i32) rishka_sc_0(RISHKA_SC_IO_PEEK);
}

bool IO::find(string target, usize size) {
return (bool) rishka_sc_2(RISHKA_SC_IO_FIND, (i64) target, (i64) size);
}

bool IO::find_until(string target, string terminator) {
return (bool) rishka_sc_2(RISHKA_SC_IO_FIND_UNTIL, (i64) target, (i64) terminator);
}

void IO::set_timeout(u64 timeout) {
rishka_sc_1(RISHKA_SC_IO_SET_TIMEOUT, (i64) timeout);
}

u64 IO::get_timeout() {
return (u64) rishka_sc_0(RISHKA_SC_IO_GET_TIMEOUT);
}

void Sys::delay(u64 ms) {
rishka_sc_1(RISHKA_SC_SYS_DELAY_MS, (long) ms);
}
Expand Down

0 comments on commit 6e8c2ed

Please sign in to comment.