diff --git a/Cargo.toml b/Cargo.toml index 491fa6038719f..024c79064c922 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,6 +22,7 @@ targets = [ "aarch64-pc-windows-msvc", "aarch64-unknown-freebsd", "aarch64-unknown-fuchsia", + "aarch64-unknown-helenos", "aarch64-unknown-hermit", "aarch64-unknown-linux-gnu", "aarch64-unknown-linux-musl", @@ -53,6 +54,7 @@ targets = [ "i686-pc-windows-msvc", "i686-unknown-freebsd", "i686-unknown-haiku", + "i686-unknown-helenos", "i686-unknown-linux-gnu", "i686-unknown-linux-musl", "i686-unknown-netbsd", @@ -68,6 +70,7 @@ targets = [ "mipsel-unknown-linux-gnu", "mipsel-unknown-linux-musl", "nvptx64-nvidia-cuda", + "powerpc-unknown-helenos", "powerpc-unknown-linux-gnu", "powerpc-unknown-linux-gnuspe", "powerpc-unknown-netbsd", @@ -94,6 +97,7 @@ targets = [ "s390x-unknown-linux-gnu", "s390x-unknown-linux-musl", "sparc-unknown-linux-gnu", + "sparc64-unknown-helenos", "sparc64-unknown-linux-gnu", "sparc64-unknown-netbsd", "sparcv9-sun-solaris", @@ -116,6 +120,7 @@ targets = [ "x86_64-unknown-freebsd", "x86_64-unknown-fuchsia", "x86_64-unknown-haiku", + "x86_64-unknown-helenos", "x86_64-unknown-hermit", "x86_64-unknown-illumos", "x86_64-unknown-l4re-uclibc", diff --git a/build.rs b/build.rs index 0a3d39d16abb6..30f45a129153f 100644 --- a/build.rs +++ b/build.rs @@ -29,7 +29,7 @@ const CHECK_CFG_EXTRA: &[(&str, &[&str])] = &[ ( "target_os", &[ - "switch", "aix", "ohos", "hurd", "rtems", "visionos", "nuttx", "cygwin", + "switch", "aix", "ohos", "hurd", "rtems", "visionos", "nuttx", "cygwin", "helenos", ], ), ( diff --git a/ci/verify-build.py b/ci/verify-build.py index 483dc5cfa96fb..79c53f87a4ee1 100755 --- a/ci/verify-build.py +++ b/ci/verify-build.py @@ -137,6 +137,7 @@ def __post_init__(self): # there is no need to do this given the target tier policy, but the cost is small # and the saved churn from accidental breakage is significant, so we keep it around. Target("aarch64-unknown-freebsd", dist=False), + Target("aarch64-unknown-helenos", dist=False), Target("aarch64-unknown-hermit", dist=False), Target("aarch64-unknown-illumos", dist=False), Target("aarch64-unknown-netbsd", dist=False), @@ -151,6 +152,7 @@ def __post_init__(self): Target("i386-apple-ios", dist=False), Target("i686-apple-darwin", dist=False), Target("i686-unknown-haiku", dist=False), + Target("i686-unknown-helenos", dist=False), Target("i686-unknown-hurd-gnu", dist=False), Target("i686-unknown-netbsd", dist=False), Target("i686-unknown-openbsd", dist=False), @@ -164,6 +166,7 @@ def __post_init__(self): Target("mipsel-unknown-linux-gnu", dist=False), Target("mipsel-unknown-linux-musl", dist=False), Target("nvptx64-nvidia-cuda", dist=False), + Target("powerpc-unknown-helenos", dist=False), Target("powerpc-unknown-linux-gnuspe", dist=False), Target("powerpc-unknown-netbsd", dist=False), Target("powerpc-wrs-vxworks", dist=False), @@ -185,6 +188,7 @@ def __post_init__(self): Target("riscv64imac-unknown-none-elf", dist=False), Target("s390x-unknown-linux-musl", dist=False), Target("sparc-unknown-linux-gnu", dist=False), + Target("sparc64-unknown-helenos", dist=False), Target("sparc64-unknown-netbsd", dist=False), Target("thumbv7em-none-eabihf", dist=False), Target("thumbv7m-none-eabi", dist=False), @@ -193,6 +197,7 @@ def __post_init__(self): Target("thumbv8m.main-none-eabi", dist=False), Target("x86_64-unknown-dragonfly", dist=False), Target("x86_64-unknown-haiku", dist=False), + Target("x86_64-unknown-helenos", dist=False), Target("x86_64-unknown-hermit", dist=False), Target("x86_64-unknown-l4re-uclibc", dist=False), Target("x86_64-unknown-openbsd", dist=False), diff --git a/src/helenos.rs b/src/helenos.rs new file mode 100644 index 0000000000000..a8fa35eb963c8 --- /dev/null +++ b/src/helenos.rs @@ -0,0 +1,78 @@ +use crate::prelude::*; +use crate::{ + errno_t, + timespec, +}; + +pub type intmax_t = i64; +pub type uintmax_t = u64; +pub type intptr_t = isize; +pub type uintptr_t = usize; +pub type size_t = usize; +pub type ssize_t = isize; + +// uspace/lib/posix/include/posix/pthread.h +pub type pthread_key_t = c_int; + +// uspace/lib/posix/include/posix/sys/types.h +pub type clockid_t = c_int; +pub type pid_t = c_int; + +s! { + // common/include/adt/list.h + pub struct link_t { + pub next: *mut link_t, + pub prev: *mut link_t, + } + + pub struct list_t { + pub head: link_t, + } +} + +// uspace/lib/posix/include/posix/time.h +pub const CLOCK_REALTIME: clockid_t = 0; +pub const CLOCK_MONOTONIC: clockid_t = 1; + +// 'static inline' functions from libc +// common/include/adt/list.h +f! { + pub fn list_initialize(list: *mut list_t) -> () { + let list = &mut *list; + list.head.next = &mut list.head; + list.head.prev = &mut list.head; + } +} + +extern "C" { + // common/include/str_error.h + pub fn str_error(err: errno_t) -> *const c_char; + pub fn str_error_name(err: errno_t) -> *const c_char; + + // uspace/lib/posix/include/posix/pthread.h + pub fn pthread_key_create( + key: *mut pthread_key_t, + destructor: unsafe extern "C" fn(*mut c_void), + ) -> c_int; + pub fn pthread_getspecific(key: pthread_key_t) -> *mut c_void; + pub fn pthread_setspecific(key: pthread_key_t, value: *const c_void) -> c_int; + pub fn pthread_key_delete(key: pthread_key_t) -> c_int; + + // uspace/lib/posix/include/posix/time.h + pub fn clock_getres(clock_id: clockid_t, res: *mut timespec) -> c_int; + pub fn clock_gettime(clock_id: clockid_t, tp: *mut timespec) -> c_int; + pub fn clock_settime(clock_id: clockid_t, tp: *const timespec) -> c_int; + pub fn clock_nanosleep( + clock_id: clockid_t, + flags: c_int, + rqtp: *const timespec, + rmtp: *mut timespec, + ) -> c_int; + + // uspace/lib/posix/include/posix/unistd.h + pub fn getpid() -> pid_t; + pub fn getcwd(buf: *mut c_char, size: size_t) -> *mut c_char; + pub fn chdir(buf: *const c_char) -> c_int; + pub static environ: *const *const c_char; + pub fn isatty(fd: c_int) -> c_int; +} diff --git a/src/lib.rs b/src/lib.rs index a29bf354f5f9d..2f499059630b6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -93,6 +93,14 @@ cfg_if! { mod unix; pub use crate::unix::*; + prelude!(); + } else if #[cfg(target_os = "helenos")] { + mod primitives; + pub use primitives::*; + + mod helenos; + pub use self::helenos::*; + prelude!(); } else if #[cfg(target_os = "hermit")] { mod primitives; diff --git a/src/new/helenos/abi/errno.rs b/src/new/helenos/abi/errno.rs new file mode 100644 index 0000000000000..040298a720359 --- /dev/null +++ b/src/new/helenos/abi/errno.rs @@ -0,0 +1,43 @@ +//! HelenOS errno codes +//! +//! * Header file: + +use crate::errno_t; + +pub const EOK: errno_t = 0; +pub const ENOENT: errno_t = 1; +pub const ENOMEM: errno_t = 2; +pub const ELIMIT: errno_t = 3; +pub const EREFUSED: errno_t = 4; +pub const EFORWARD: errno_t = 5; +pub const EPERM: errno_t = 6; +pub const EHANGUP: errno_t = 7; +pub const EPARTY: errno_t = 8; +pub const EEXIST: errno_t = 9; +pub const EBADMEM: errno_t = 10; +pub const ENOTSUP: errno_t = 11; +pub const EADDRNOTAVAIL: errno_t = 12; +pub const ETIMEOUT: errno_t = 13; +pub const EINVAL: errno_t = 14; +pub const EBUSY: errno_t = 15; +pub const EOVERFLOW: errno_t = 16; +pub const EINTR: errno_t = 17; +pub const EMFILE: errno_t = 18; +pub const ENAMETOOLONG: errno_t = 19; +pub const EISDIR: errno_t = 20; +pub const ENOTDIR: errno_t = 21; +pub const ENOSPC: errno_t = 22; +pub const ENOTEMPTY: errno_t = 23; +pub const EBADF: errno_t = 24; +pub const EDOM: errno_t = 25; +pub const ERANGE: errno_t = 26; +pub const EXDEV: errno_t = 27; +pub const EIO: errno_t = 28; +pub const EMLINK: errno_t = 29; +pub const ENXIO: errno_t = 30; +pub const ENOFS: errno_t = 31; +pub const EBADCHECKSUM: errno_t = 32; +pub const ESTALL: errno_t = 33; +pub const EEMPTY: errno_t = 34; +pub const ENAK: errno_t = 35; +pub const EAGAIN: errno_t = 36; diff --git a/src/new/helenos/bits.rs b/src/new/helenos/bits.rs new file mode 100644 index 0000000000000..bcb704d8cb038 --- /dev/null +++ b/src/new/helenos/bits.rs @@ -0,0 +1,9 @@ +//! HelenOS ABI bits +//! +//! * Headers: + +// `errno.h` +pub type errno_t = crate::c_int; + +// `native.h` +pub type sysarg_t = crate::uintptr_t; diff --git a/src/new/helenos/dirent_mod.rs b/src/new/helenos/dirent_mod.rs new file mode 100644 index 0000000000000..089a5a5fbf3c6 --- /dev/null +++ b/src/new/helenos/dirent_mod.rs @@ -0,0 +1,29 @@ +//! HelenOS directory entry API +//! +//! * Header file: + +// The module is named to avoid name collision with the dirent struct, which causes issues with +// wildcard imports in the parent module. + +use crate::{ + c_char, + c_int, +}; + +s! { + pub struct dirent { + pub d_name: [c_char; 256], + } +} + +extern_ty! { + pub enum DIR {} +} + +extern "C" { + pub fn opendir(name: *const c_char) -> *mut DIR; + pub fn readdir(dir: *mut DIR) -> *mut dirent; + pub fn closedir(dir: *mut DIR) -> c_int; + pub fn rewinddir(dir: *mut DIR); + +} diff --git a/src/new/helenos/errno.rs b/src/new/helenos/errno.rs new file mode 100644 index 0000000000000..09b303fa5fa3e --- /dev/null +++ b/src/new/helenos/errno.rs @@ -0,0 +1,7 @@ +//! HelenOS errno handling +//! +//! * Header file: + +extern "C" { + pub fn __errno() -> *mut crate::errno_t; +} diff --git a/src/new/helenos/fibril.rs b/src/new/helenos/fibril.rs new file mode 100644 index 0000000000000..e480a6ff994c5 --- /dev/null +++ b/src/new/helenos/fibril.rs @@ -0,0 +1,36 @@ +//! HelenOS fibrils API +//! +//! * Header file: + +pub use crate::time::*; +use crate::{ + c_void, + errno_t, + size_t, +}; + +pub type fid_t = *mut fibril_t; + +s! { + pub struct fibril_owner_info_t { + pub owned_by: *mut fibril_t, + } +} + +extern_ty! { + pub enum fibril_t {} +} + +extern "C" { + pub fn fibril_create_generic( + func: extern "C" fn(*mut c_void) -> errno_t, + arg: *mut c_void, + stacksize: size_t, + ) -> fid_t; + pub fn fibril_start(f: fid_t); + pub fn fibril_exit(retval: c_long) -> !; + pub fn fibril_detach(f: fid_t); + pub fn fibril_yield(); + pub fn fibril_usleep(usec: usec_t); + pub fn fibril_get_id() -> fid_t; +} diff --git a/src/new/helenos/fibril_synch.rs b/src/new/helenos/fibril_synch.rs new file mode 100644 index 0000000000000..0ad4fea2e1c09 --- /dev/null +++ b/src/new/helenos/fibril_synch.rs @@ -0,0 +1,49 @@ +//! HelenOS fibril synchronization primitives +//! +//! * Header file: + +pub use crate::fibril::*; +use crate::{ + c_int, + errno_t, + list_initialize, + list_t, +}; + +s! { + pub struct fibril_mutex_t { + pub oi: fibril_owner_info_t, + pub counter: c_int, + pub waiters: list_t, + } + + pub struct fibril_condvar_t { + pub waiters: list_t, + } +} + +f! { + pub fn fibril_mutex_initialize(fm: *mut fibril_mutex_t) -> () { + let fm = &mut *fm; + fm.oi.owned_by = core::ptr::null_mut(); + fm.counter = 1; + list_initialize(&mut fm.waiters); + } +} + +extern "C" { + pub fn fibril_mutex_lock(mutex: *mut fibril_mutex_t); + pub fn fibril_mutex_unlock(mutex: *mut fibril_mutex_t); + pub fn fibril_mutex_trylock(mutex: *mut fibril_mutex_t) -> bool; + pub fn fibril_mutex_is_locked(mutex: *mut fibril_mutex_t) -> bool; + + pub fn fibril_condvar_initialize(condvar: *mut fibril_condvar_t); + pub fn fibril_condvar_wait(condvar: *mut fibril_condvar_t, mutex: *mut fibril_mutex_t); + pub fn fibril_condvar_wait_timeout( + condvar: *mut fibril_condvar_t, + mutex: *mut fibril_mutex_t, + timeout: usec_t, + ) -> errno_t; + pub fn fibril_condvar_signal(condvar: *mut fibril_condvar_t); + pub fn fibril_condvar_broadcast(condvar: *mut fibril_condvar_t); +} diff --git a/src/new/helenos/inet/addr.rs b/src/new/helenos/inet/addr.rs new file mode 100644 index 0000000000000..e00bb2b821e18 --- /dev/null +++ b/src/new/helenos/inet/addr.rs @@ -0,0 +1,26 @@ +//! HelenOS internet address types +//! +//! * Header file: + +pub type addr32_t = u32; +pub type addr128_t = [u8; 16]; + +c_enum! { + #[repr(u32)] + pub enum ip_ver_t { + ip_any, + ip_v4, + ip_v6, + } +} +s_no_extra_traits! { + pub union __inet_addr_t_addr_union { + pub addr: addr32_t, + pub addr6: addr128_t, + } + + pub struct inet_addr_t { + pub version: ip_ver_t, + pub addr: __inet_addr_t_addr_union, + } +} diff --git a/src/new/helenos/inet/dnsr.rs b/src/new/helenos/inet/dnsr.rs new file mode 100644 index 0000000000000..05b81c52dbee5 --- /dev/null +++ b/src/new/helenos/inet/dnsr.rs @@ -0,0 +1,25 @@ +//! HelenOS DNS resolver API +//! +//! * Header file: + +pub use crate::inet::addr::*; +use crate::{ + c_char, + errno_t, +}; + +s_no_extra_traits! { + pub struct dnsr_hostinfo_t { + pub cname: *mut c_char, + pub addr: inet_addr_t, + } +} + +extern "C" { + pub fn dnsr_name2host( + name: *const c_char, + info: *mut *mut dnsr_hostinfo_t, + ipver: ip_ver_t, + ) -> errno_t; + pub fn dnsr_hostinfo_destroy(info: *mut dnsr_hostinfo_t); +} diff --git a/src/new/helenos/inet/endpoint.rs b/src/new/helenos/inet/endpoint.rs new file mode 100644 index 0000000000000..2f8fecc88309d --- /dev/null +++ b/src/new/helenos/inet/endpoint.rs @@ -0,0 +1,23 @@ +//! HelenOS internet endpoint types +//! +//! * Header file: + +pub use crate::inet::addr::*; +pub use crate::loc::*; + +s_no_extra_traits! { + pub struct inet_ep2_t { + pub local_link: service_id_t, + pub local: inet_ep_t, + pub remote: inet_ep_t, + } + + pub struct inet_ep_t { + pub addr: inet_addr_t, + pub port: u16, + } +} +extern "C" { + pub fn inet_ep_init(ep: *mut inet_ep_t); + pub fn inet_ep2_init(epp: *mut inet_ep2_t); +} diff --git a/src/new/helenos/inet/tcp.rs b/src/new/helenos/inet/tcp.rs new file mode 100644 index 0000000000000..2265058c2c9df --- /dev/null +++ b/src/new/helenos/inet/tcp.rs @@ -0,0 +1,76 @@ +//! HelenOS TCP API +//! +//! * Header file: + +pub use crate::inet::endpoint::*; +use crate::{ + c_void, + errno_t, + size_t, +}; + +s_no_extra_traits! { + pub struct tcp_cb_t { + pub connected: extern "C" fn(conn: *mut tcp_conn_t), + pub conn_failed: extern "C" fn(conn: *mut tcp_conn_t), + pub conn_reset: extern "C" fn(conn: *mut tcp_conn_t), + pub data_avail: extern "C" fn(conn: *mut tcp_conn_t), + pub urg_data: extern "C" fn(conn: *mut tcp_conn_t), + } + pub struct tcp_listen_cb_t { + pub new_conn: extern "C" fn(listener: *mut tcp_listener_t, conn: *mut tcp_conn_t), + } +} + +extern_ty! { + pub enum tcp_t {} + pub enum tcp_conn_t {} + pub enum tcp_listener_t {} +} + +extern "C" { + pub fn tcp_create(tcp: *mut *mut tcp_t) -> errno_t; + pub fn tcp_destroy(tcp: *mut tcp_t); + + pub fn tcp_conn_create( + tcp: *mut tcp_t, + epp: *mut inet_ep2_t, + callbacks: *mut tcp_cb_t, + arg: *mut c_void, + conn: *mut *mut tcp_conn_t, + ) -> errno_t; + pub fn tcp_conn_destroy(conn: *mut tcp_conn_t); + + pub fn tcp_listener_create( + tcp: *mut tcp_t, + ep: *mut inet_ep_t, + listen_callbacks: *mut tcp_listen_cb_t, + listen_arg: *mut c_void, + conn_callbacks: *mut tcp_cb_t, + conn_arg: *mut c_void, + listener: *mut *mut tcp_listener_t, + ) -> errno_t; + pub fn tcp_listener_destroy(listener: *mut tcp_listener_t); + + pub fn tcp_conn_userptr(conn: *mut tcp_conn_t) -> *mut c_void; + pub fn tcp_listener_userptr(listener: *mut tcp_listener_t) -> *mut c_void; + + pub fn tcp_conn_wait_connected(conn: *mut tcp_conn_t) -> errno_t; + pub fn tcp_conn_send(conn: *mut tcp_conn_t, buf: *const c_void, len: size_t) -> errno_t; + pub fn tcp_conn_send_fin(conn: *mut tcp_conn_t) -> errno_t; + pub fn tcp_conn_push(conn: *mut tcp_conn_t) -> errno_t; + pub fn tcp_conn_reset(conn: *mut tcp_conn_t) -> errno_t; + + pub fn tcp_conn_recv( + conn: *mut tcp_conn_t, + buf: *mut c_void, + bufsize: size_t, + received_len: *mut size_t, + ) -> errno_t; + pub fn tcp_conn_recv_wait( + conn: *mut tcp_conn_t, + buf: *mut c_void, + bufsize: size_t, + received_len: *mut size_t, + ) -> errno_t; +} diff --git a/src/new/helenos/ipc/mod.rs b/src/new/helenos/ipc/mod.rs new file mode 100644 index 0000000000000..f7fa66ec789c3 --- /dev/null +++ b/src/new/helenos/ipc/mod.rs @@ -0,0 +1,12 @@ +//! HelenOS IPC types +//! +//! Headers: + +pub(crate) mod loc { + pub type service_id_t = crate::sysarg_t; +} + +pub(crate) mod vfs { + pub type fs_handle_t = i16; + pub type fs_index_t = u32; +} diff --git a/src/new/helenos/loc.rs b/src/new/helenos/loc.rs new file mode 100644 index 0000000000000..0cf367785713b --- /dev/null +++ b/src/new/helenos/loc.rs @@ -0,0 +1,5 @@ +//! HelenOS libc/loc +//! +//! * Header file: + +pub use crate::ipc::loc::*; diff --git a/src/new/helenos/mod.rs b/src/new/helenos/mod.rs new file mode 100644 index 0000000000000..5da156d05eda6 --- /dev/null +++ b/src/new/helenos/mod.rs @@ -0,0 +1,27 @@ +//! HelenOS libraries +//! +//! * HelenOS source tree: (libraries are in uspace/lib, some bits are in abi and common) + +pub(crate) mod abi { + pub(crate) mod errno; +} +pub(crate) mod bits; +pub(crate) mod dirent_mod; +pub(crate) mod errno; +pub(crate) mod fibril; +pub(crate) mod fibril_synch; +pub(crate) mod inet { + pub(crate) mod addr; + pub(crate) mod dnsr; + pub(crate) mod endpoint; + pub(crate) mod tcp; +} +pub(crate) mod ipc; +pub(crate) mod loc; +pub(crate) mod offset; +pub(crate) mod stdio; +pub(crate) mod stdlib; +pub(crate) mod time; +pub(crate) mod vfs { + pub(crate) mod vfs; +} diff --git a/src/new/helenos/offset.rs b/src/new/helenos/offset.rs new file mode 100644 index 0000000000000..131d3d72f09ca --- /dev/null +++ b/src/new/helenos/offset.rs @@ -0,0 +1,5 @@ +//! HelenOS libc offset types +//! +//! * Header file: + +pub type aoff64_t = u64; diff --git a/src/new/helenos/stdio.rs b/src/new/helenos/stdio.rs new file mode 100644 index 0000000000000..953105fdc379d --- /dev/null +++ b/src/new/helenos/stdio.rs @@ -0,0 +1,34 @@ +//! HelenOS libc standard I/O APIs +//! +//! * Header file: + +use crate::prelude::*; + +pub const SEEK_SET: c_int = 0; +pub const SEEK_CUR: c_int = 1; +pub const SEEK_END: c_int = 2; + +extern_ty! { + pub enum FILE {} +} + +extern "C" { + pub static stdin: *mut FILE; + pub static stdout: *mut FILE; + pub static stderr: *mut FILE; + + pub fn fputc(c: c_int, stream: *mut FILE) -> c_int; + pub fn fputs(s: *const c_char, stream: *mut FILE) -> c_int; + + pub fn fopen(filename: *const c_char, mode: *const c_char) -> *mut FILE; + pub fn fclose(stream: *mut FILE) -> c_int; + pub fn fflush(stream: *mut FILE) -> c_int; + + pub fn fread(buf: *mut c_void, size: size_t, nmemb: size_t, stream: *mut FILE) -> size_t; + pub fn fwrite(buf: *const c_void, size: size_t, nmemb: size_t, stream: *mut FILE) -> size_t; + + pub fn fseek(stream: *mut FILE, offset: c_long, whence: c_int) -> c_int; + pub fn ftell(stream: *mut FILE) -> c_long; + + pub fn fileno(stream: *mut FILE) -> c_int; +} diff --git a/src/new/helenos/stdlib.rs b/src/new/helenos/stdlib.rs new file mode 100644 index 0000000000000..1f92a3de4fa55 --- /dev/null +++ b/src/new/helenos/stdlib.rs @@ -0,0 +1,18 @@ +use crate::prelude::*; + +extern "C" { + pub fn malloc(size: usize) -> *mut c_void; + pub fn calloc(nmemb: usize, size: usize) -> *mut c_void; + pub fn realloc(addr: *mut c_void, size: usize) -> *mut c_void; + pub fn free(addr: *mut c_void); + + pub fn memalign(align: usize, size: usize) -> *mut c_void; + + pub fn rand() -> c_int; + pub fn srand(seed: c_uint); + + pub fn exit(code: c_int) -> !; + pub fn abort() -> !; + + pub fn getenv(env: *const c_char) -> *mut c_char; +} diff --git a/src/new/helenos/time.rs b/src/new/helenos/time.rs new file mode 100644 index 0000000000000..ef6b72d921a44 --- /dev/null +++ b/src/new/helenos/time.rs @@ -0,0 +1,22 @@ +//! HelenOS time handling +//! +//! * Header file: + +pub use crate::{ + c_long, + c_longlong, +}; + +pub type time_t = c_longlong; +pub type usec_t = c_longlong; + +s! { + pub struct timespec { + pub tv_sec: time_t, + pub tv_nsec: c_long, + } +} + +extern "C" { + pub fn getuptime(tp: *mut timespec); +} diff --git a/src/new/helenos/vfs/vfs.rs b/src/new/helenos/vfs/vfs.rs new file mode 100644 index 0000000000000..025d5ab9d213b --- /dev/null +++ b/src/new/helenos/vfs/vfs.rs @@ -0,0 +1,47 @@ +//! HelenOS libc virtual file system APIs +//! +//! * Header file: + +pub use crate::ipc::loc::*; +pub use crate::ipc::vfs::*; +pub use crate::offset::*; +pub use crate::stdio::*; +use crate::{ + c_char, + c_int, + c_uint, + errno_t, +}; + +s! { + pub struct vfs_stat_t { + pub fs_handle: fs_handle_t, + pub service_id: service_id_t, + pub index: fs_index_t, + pub lnkcnt: c_uint, + pub is_file: bool, + pub is_directory: bool, + pub size: aoff64_t, + pub service: service_id_t, + } +} + +c_enum! { + pub enum vfs_file_kind_t { + KIND_FILE, + KIND_DIRECTORY, + } +} + +extern "C" { + pub fn vfs_fhandle(file: *mut FILE, handle: *mut c_int) -> errno_t; + pub fn vfs_stat(handle: c_int, stat: *mut vfs_stat_t) -> errno_t; + pub fn vfs_link_path( + path: *const c_char, + kind: vfs_file_kind_t, + linkedfd: *mut c_int, + ) -> errno_t; + pub fn vfs_unlink_path(path: *const c_char) -> errno_t; + pub fn vfs_rename_path(oldpath: *const c_char, newpath: *const c_char) -> errno_t; + pub fn vfs_stat_path(path: *const c_char, stat: *mut vfs_stat_t) -> errno_t; +} diff --git a/src/new/mod.rs b/src/new/mod.rs index 38a0759afb65d..8591a3428f108 100644 --- a/src/new/mod.rs +++ b/src/new/mod.rs @@ -73,6 +73,9 @@ cfg_if! { } else if #[cfg(target_os = "haiku")] { mod haiku; pub(crate) use haiku::*; + } else if #[cfg(target_os = "helenos")] { + mod helenos; + pub(crate) use helenos::*; } else if #[cfg(target_os = "hermit")] { mod hermit_abi; // pub(crate) use hermit_abi::*; @@ -193,6 +196,20 @@ cfg_if! { pub use utmpx_::*; } else if #[cfg(target_os = "openbsd")] { pub use sys::ipc::*; + } else if #[cfg(target_os = "helenos")] { + pub use abi::errno::*; + pub use bits::*; + pub use dirent_mod::*; + pub use errno::*; + pub use fibril::*; + pub use fibril_synch::*; + pub use inet::dnsr::*; + pub use inet::endpoint::*; + pub use inet::tcp::*; + pub use ipc::vfs::*; + pub use stdio::*; + pub use stdlib::*; + pub use vfs::vfs::*; } }