-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Add HelenOS support #4355
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
Merged
Merged
Add HelenOS support #4355
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| 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 safe fn list_initialize(list: &mut list_t) -> () { | ||
| 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: Option<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; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| //! HelenOS errno codes | ||
| //! | ||
| //! * Header file: <https://github.com/HelenOS/helenos/tree/master/abi/include/abi/errno.h> | ||
|
|
||
| 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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| //! HelenOS ABI bits | ||
| //! | ||
| //! * Headers: <https://github.com/HelenOS/helenos/tree/master/abi/include/_bits> | ||
|
|
||
| // `errno.h` | ||
| pub type errno_t = crate::c_int; | ||
|
|
||
| // `native.h` | ||
| pub type sysarg_t = crate::uintptr_t; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| //! HelenOS directory entry API | ||
| //! | ||
| //! * Header file: <https://github.com/HelenOS/helenos/tree/master/uspace/lib/c/include/dirent.h> | ||
|
|
||
| // The module is named to avoid name collision with the dirent struct, which causes issues with | ||
| // wildcard imports in the parent module. | ||
|
|
||
| use crate::prelude::*; | ||
|
|
||
| s! { | ||
| pub struct dirent { | ||
| pub d_name: [c_char; 256], | ||
| } | ||
| } | ||
|
|
||
| extern_ty! { | ||
| pub type 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); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| //! HelenOS errno handling | ||
| //! | ||
| //! * Header file: <https://github.com/HelenOS/helenos/tree/master/uspace/lib/c/include/errno.h> | ||
|
|
||
| extern "C" { | ||
| pub fn __errno() -> *mut crate::errno_t; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| //! HelenOS fibrils API | ||
| //! | ||
| //! * Header file: <https://github.com/HelenOS/helenos/tree/master/uspace/lib/c/include/fibril.h> | ||
|
|
||
| use crate::errno_t; | ||
| use crate::prelude::*; | ||
| pub use crate::time::*; | ||
|
|
||
| pub type fid_t = *mut fibril_t; | ||
|
|
||
| s! { | ||
| pub struct fibril_owner_info_t { | ||
| pub owned_by: *mut fibril_t, | ||
| } | ||
| } | ||
|
|
||
| extern_ty! { | ||
| pub type fibril_t; | ||
| } | ||
|
|
||
| extern "C" { | ||
| pub fn fibril_create_generic( | ||
| func: unsafe 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; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| //! HelenOS fibril synchronization primitives | ||
| //! | ||
| //! * Header file: <https://github.com/HelenOS/helenos/tree/master/uspace/lib/c/include/fibril_synch.h> | ||
|
|
||
| pub use crate::fibril::*; | ||
| use crate::prelude::*; | ||
| use crate::{ | ||
| 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_rwlock_t { | ||
| pub oi: fibril_owner_info_t, | ||
| pub writers: c_uint, | ||
| pub readers: c_uint, | ||
| pub waiters: list_t, | ||
| } | ||
|
|
||
| pub struct fibril_condvar_t { | ||
| pub waiters: list_t, | ||
| } | ||
| } | ||
|
|
||
| f! { | ||
| pub safe fn fibril_mutex_initialize(fm: &mut fibril_mutex_t) -> () { | ||
| fm.oi.owned_by = 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_rwlock_initialize(rwlock: *mut fibril_rwlock_t); | ||
| pub fn fibril_rwlock_read_lock(rwlock: *mut fibril_rwlock_t); | ||
| pub fn fibril_rwlock_write_lock(rwlock: *mut fibril_rwlock_t); | ||
| pub fn fibril_rwlock_read_unlock(rwlock: *mut fibril_rwlock_t); | ||
| pub fn fibril_rwlock_write_unlock(rwlock: *mut fibril_rwlock_t); | ||
| pub fn fibril_rwlock_is_read_locked(rwlock: *mut fibril_rwlock_t) -> bool; | ||
| pub fn fibril_rwlock_is_write_locked(rwlock: *mut fibril_rwlock_t) -> bool; | ||
| pub fn fibril_rwlock_is_locked(rwlock: *mut fibril_rwlock_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); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| //! HelenOS internet address types | ||
| //! | ||
| //! * Header file: <https://github.com/HelenOS/helenos/tree/master/uspace/lib/inet/include/inet/addr.h> | ||
|
|
||
| pub type addr32_t = u32; | ||
| pub type addr128_t = [u8; 16]; | ||
|
|
||
| c_enum! { | ||
| #[repr(u32)] | ||
| pub enum ip_ver_t { | ||
| pub ip_any, | ||
| pub ip_v4, | ||
| pub 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, | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.