Skip to content
39 changes: 39 additions & 0 deletions crates/illumos-sys-hdrs/src/kernel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,8 @@ unsafe extern "C" {

pub type queue_t; // Definitely not using STREAMS.

pub type kthread_t;

// DDI/DKI 9F
pub fn allocb(size: size_t, pri: c_uint) -> *mut mblk_t;

Expand Down Expand Up @@ -576,6 +578,43 @@ unsafe extern "C" {
pub fn rw_tryupgrade(rwlp: *mut krwlock_t);
pub fn rw_read_locked(rwlp: *mut krwlock_t);

pub fn cv_init(
cvp: *mut kcondvar_t,
name: *const c_char,
cv_type: kcv_type_t,
arg: *mut c_void,
);
pub fn cv_destroy(cvp: *mut kcondvar_t);
pub fn cv_wait(cvp: *mut kcondvar_t, mp: *mut kmutex_t);
pub fn cv_signal(cvp: *mut kcondvar_t);
pub fn cv_broadcast(cvp: *mut kcondvar_t);
pub fn cv_wait_sig(cvp: *mut kcondvar_t, mp: *mut kmutex_t) -> c_int;
pub fn cv_timedwait(
cvp: *mut kcondvar_t,
mp: *mut kmutex_t,
timeout: clock_t,
) -> clock_t;
pub fn cv_timedwait_sig(
cvp: *mut kcondvar_t,
mp: *mut kmutex_t,
timeout: clock_t,
) -> clock_t;
pub fn cv_reltimedwait(
cvp: *mut kcondvar_t,
mp: *mut kmutex_t,
delta: clock_t,
res: time_res_t,
) -> clock_t;
pub fn cv_reltimedwait_sig(
cvp: *mut kcondvar_t,
mp: *mut kmutex_t,
delta: clock_t,
res: time_res_t,
) -> clock_t;

// Underlies the `curthread` macro in kernel.
pub fn threadp() -> *mut kthread_t;

pub fn nochpoll() -> c_int;
pub fn nodev() -> c_int;
pub fn nulldev() -> c_int;
Expand Down
30 changes: 30 additions & 0 deletions crates/illumos-sys-hdrs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,35 @@ pub enum krw_type_t {
RW_DEFAULT = 4,
}

// ======================================================================
// uts/common/sys/condvar.h
// ======================================================================

#[repr(C)]
pub struct kcondvar_t {
pub _opaque: c_ushort,
}

#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct kcv_type_t(pub c_int);
impl kcv_type_t {
pub const CV_DEFAULT: Self = Self(0);
pub const CV_DRIVER: Self = Self(1);
}

#[repr(transparent)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct time_res_t(pub c_int);
impl time_res_t {
pub const TR_NANOSEC: Self = Self(0);
pub const TR_MICROSEC: Self = Self(1);
pub const TR_MILLISEC: Self = Self(2);
pub const TR_SEC: Self = Self(3);
pub const TR_CLOCK_TICK: Self = Self(4);
pub const TR_COUNT: Self = Self(5);
}

// ======================================================================
// uts/common/sys/stream.h
// ======================================================================
Expand Down Expand Up @@ -323,6 +352,7 @@ pub type hrtime_t = c_longlong;
// ======================================================================
// uts/common/sys/types.h
// ======================================================================
pub type clock_t = c_long;
pub type datalink_id_t = uint32_t;
pub type dev_t = c_ulong;
pub type id_t = c_int;
Expand Down
Loading