-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Haiku bsd #4221
Open
nielx
wants to merge
2
commits into
rust-lang:main
Choose a base branch
from
nielx:haiku-bsd
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Haiku bsd #4221
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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 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,151 @@ | ||
use crate::prelude::*; | ||
|
||
// This file contains the BSD APIs available in Haiku. It corresponds to the | ||
// header files in `headers/compatibility/bsd`. | ||
// | ||
// Note that Haiku's BSD compatibility is a combination of system APIs and | ||
// utility libraries. There should only be system APIs in `libc`. When you are | ||
// trying to determine whether something should be included in this file, the | ||
// best indicator is whether it also exists in the BSD-specific definitions in | ||
// this libc crate. | ||
|
||
// stringlist.h (utility library) | ||
// Note: this is kept because it was previously introduced | ||
pub type StringList = _stringlist; | ||
|
||
s! { | ||
// stringlist.h (utility library) | ||
// Note: this is kept because it was previously introduced | ||
pub struct _stringlist { | ||
pub sl_str: *mut *mut c_char, | ||
pub sl_max: size_t, | ||
pub sl_cur: size_t, | ||
} | ||
|
||
// sys/event.h | ||
pub struct kevent { | ||
pub ident: crate::uintptr_t, | ||
pub filter: c_short, | ||
pub flags: c_ushort, | ||
pub fflags: c_uint, | ||
pub data: i64, | ||
pub udata: *mut c_void, | ||
pub ext: [u64; 4], | ||
} | ||
|
||
// sys/link_elf.h | ||
pub struct dl_phdr_info { | ||
pub dlpi_addr: crate::Elf_Addr, | ||
pub dlpi_name: *const c_char, | ||
pub dlpi_phdr: *const crate::Elf_Phdr, | ||
pub dlpi_phnum: crate::Elf_Half, | ||
} | ||
} | ||
|
||
// sys/event.h | ||
pub const EVFILT_READ: i16 = -1; | ||
pub const EVFILT_WRITE: i16 = -2; | ||
pub const EVFILT_PROC: i16 = -5; | ||
pub const EV_ADD: u16 = 0x0001; | ||
pub const EV_DELETE: u16 = 0x0002; | ||
pub const EV_ONESHOT: u16 = 0x0010; | ||
pub const EV_CLEAR: u16 = 0x0020; | ||
pub const EV_EOF: u16 = 0x8000; | ||
pub const EV_ERROR: u16 = 0x4000; | ||
pub const NOTE_EXIT: u32 = 0x80000000; | ||
|
||
// sys/ioccom.h | ||
pub const IOC_VOID: c_ulong = 0x20000000; | ||
pub const IOC_OUT: c_ulong = 0x40000000; | ||
pub const IOC_IN: c_ulong = 0x80000000; | ||
pub const IOC_INOUT: c_ulong = IOC_IN | IOC_OUT; | ||
pub const IOC_DIRMASK: c_ulong = 0xe0000000; | ||
|
||
#[link(name = "bsd")] | ||
extern "C" { | ||
// stdlib.h | ||
pub fn daemon(nochdir: c_int, noclose: c_int) -> c_int; | ||
pub fn getprogname() -> *const c_char; | ||
pub fn setprogname(progname: *const c_char); | ||
pub fn arc4random() -> u32; | ||
pub fn arc4random_uniform(upper_bound: u32) -> u32; | ||
pub fn arc4random_buf(buf: *mut c_void, n: size_t); | ||
pub fn mkstemps(template: *mut c_char, suffixlen: c_int) -> c_int; | ||
pub fn strtonum( | ||
nptr: *const c_char, | ||
minval: c_longlong, | ||
maxval: c_longlong, | ||
errstr: *mut *const c_char, | ||
) -> c_longlong; | ||
|
||
// pty.h | ||
pub fn openpty( | ||
amaster: *mut c_int, | ||
aslave: *mut c_int, | ||
name: *mut c_char, | ||
termp: *mut crate::termios, | ||
winp: *mut crate::winsize, | ||
) -> c_int; | ||
pub fn login_tty(_fd: c_int) -> c_int; | ||
pub fn forkpty( | ||
amaster: *mut c_int, | ||
name: *mut c_char, | ||
termp: *mut crate::termios, | ||
winp: *mut crate::winsize, | ||
) -> crate::pid_t; | ||
|
||
// string.h | ||
pub fn strsep(string: *mut *mut c_char, delimiters: *const c_char) -> *mut c_char; | ||
pub fn explicit_bzero(buf: *mut c_void, len: size_t); | ||
|
||
// stringlist.h (utility library) | ||
// Note: this is kept because it was previously introduced | ||
pub fn sl_init() -> *mut StringList; | ||
pub fn sl_add(sl: *mut StringList, n: *mut c_char) -> c_int; | ||
pub fn sl_free(sl: *mut StringList, i: c_int); | ||
pub fn sl_find(sl: *mut StringList, n: *mut c_char) -> *mut c_char; | ||
|
||
// sys/event.h | ||
pub fn kqueue() -> c_int; | ||
pub fn kevent( | ||
kq: c_int, | ||
changelist: *const kevent, | ||
nchanges: c_int, | ||
eventlist: *mut kevent, | ||
nevents: c_int, | ||
timeout: *const crate::timespec, | ||
) -> c_int; | ||
|
||
// sys/link_elf.h | ||
pub fn dl_iterate_phdr( | ||
callback: Option< | ||
unsafe extern "C" fn(info: *mut dl_phdr_info, size: usize, data: *mut c_void) -> c_int, | ||
>, | ||
data: *mut c_void, | ||
) -> c_int; | ||
|
||
// sys/time.h | ||
pub fn lutimes(file: *const c_char, times: *const crate::timeval) -> c_int; | ||
|
||
// sys/uov.h | ||
pub fn preadv( | ||
fd: c_int, | ||
iov: *const crate::iovec, | ||
iovcnt: c_int, | ||
offset: crate::off_t, | ||
) -> ssize_t; | ||
pub fn pwritev( | ||
fd: c_int, | ||
iov: *const crate::iovec, | ||
iovcnt: c_int, | ||
offset: crate::off_t, | ||
) -> ssize_t; | ||
|
||
// sys/wait.h | ||
pub fn wait4( | ||
pid: crate::pid_t, | ||
status: *mut c_int, | ||
options: c_int, | ||
rusage: *mut crate::rusage, | ||
) -> crate::pid_t; | ||
} |
This file contains 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 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you mind turning this into
//!
module doc comments since it's moving anyway?