#core/ds
Xu 0.16.0 API
import: #core/ds
counts: 10 functions, 24 methods, 6 types, 0 constants, 0 method sets
Zero-allocation freestanding kernel data structures intrusive doubly-linked list, bitmap allocator, and fixed-capacity ring buffer. ===== Intrusive Circular Doubly-Linked List =====
struct ListHead
pub struct ListHead {
pub prev *raw ListHead
pub next *raw ListHead
}
Purpose
Structure encapsulating prev, next.
Public fields
prev *raw ListHead- field (*raw ListHead)
next *raw ListHead- field (*raw ListHead)
list_init
pub fn list_init(head *raw ListHead)
Purpose
List init.
Parameters
head *raw ListHead- head (*raw ListHead)
Returns
This call does not return a value.
list_is_empty
pub fn list_is_empty(head *raw ListHead) bool
Purpose
Whether list is empty.
Parameters
head *raw ListHead- head (*raw ListHead)
Returns
bool — true or false
list_push_front
pub fn list_push_front(head *raw ListHead, node *raw ListHead)
Purpose
List push front.
Parameters
head *raw ListHead- head (*raw ListHead)
node *raw ListHead- node (*raw ListHead)
Returns
This call does not return a value.
list_push_back
pub fn list_push_back(head *raw ListHead, node *raw ListHead)
Purpose
List push back.
Parameters
head *raw ListHead- head (*raw ListHead)
node *raw ListHead- node (*raw ListHead)
Returns
This call does not return a value.
list_remove
pub fn list_remove(node *raw ListHead)
Purpose
List remove.
Parameters
node *raw ListHead- node (*raw ListHead)
Returns
This call does not return a value.
list_pop_front
pub fn list_pop_front(head *raw ListHead) *raw ListHead
Purpose
List pop front.
Parameters
head *raw ListHead- head (*raw ListHead)
Returns
*raw ListHead — a value of this type
struct BitMap
pub struct BitMap {
pub words *raw u64
pub num_bits usize
}
Purpose
Structure encapsulating words, num_bits.
Public fields
words *raw u64- field (*raw u64)
num_bits usize- field (usize)
bitmap_init
pub fn bitmap_init(bm *raw BitMap, words *raw u64, num_bits usize)
Purpose
Bitmap init.
Parameters
bm *raw BitMap- bm (*raw BitMap)
words *raw u64- words (*raw u64)
num_bits usize- num_bits (usize)
Returns
This call does not return a value.
(&BitMap) test
pub fn (bm &BitMap) test(idx usize) bool
Purpose
Execute test on &BitMap.
Parameters
bm &BitMap- The
BitMap instance used by this call (borrow).
idx usize- idx (usize)
Returns
bool — true or false
($&BitMap) set
pub fn (bm $&BitMap) set(idx usize)
Purpose
Execute set on $&BitMap.
Parameters
bm $&BitMap- The
BitMap instance used by this call (exclusive borrow).
idx usize- idx (usize)
Returns
This call does not return a value.
($&BitMap) clear
pub fn (bm $&BitMap) clear(idx usize)
Purpose
Clear all buffered or stored entries and internal state.
Parameters
bm $&BitMap- The
BitMap instance used by this call (exclusive borrow).
idx usize- idx (usize)
Returns
This call does not return a value.
(&BitMap) find_first_zero
pub fn (bm &BitMap) find_first_zero() isize
Purpose
Operation on &BitMap: find first zero.
Parameters
bm &BitMap- The
BitMap instance used by this call (borrow).
Returns
isize — a value of this type
($&BitMap) alloc_bit
pub fn (bm $&BitMap) alloc_bit() isize
Purpose
Operation on $&BitMap: alloc bit.
Parameters
bm $&BitMap- The
BitMap instance used by this call (exclusive borrow).
Returns
isize — a value of this type
($&BitMap) free_bit
pub fn (bm $&BitMap) free_bit(idx usize)
Purpose
Operation on $&BitMap: free bit.
Parameters
bm $&BitMap- The
BitMap instance used by this call (exclusive borrow).
idx usize- idx (usize)
Returns
This call does not return a value.
($&BitMap) set_range
pub fn (bm $&BitMap) set_range(start usize, count usize)
Purpose
Operation on $&BitMap: set range.
Parameters
bm $&BitMap- The
BitMap instance used by this call (exclusive borrow).
start usize- start (usize)
count usize- count (usize)
Returns
This call does not return a value.
($&BitMap) clear_range
pub fn (bm $&BitMap) clear_range(start usize, count usize)
Purpose
Operation on $&BitMap: clear range.
Parameters
bm $&BitMap- The
BitMap instance used by this call (exclusive borrow).
start usize- start (usize)
count usize- count (usize)
Returns
This call does not return a value.
(&BitMap) find_contiguous_zeros
pub fn (bm &BitMap) find_contiguous_zeros(count usize) isize
Purpose
Operation on &BitMap: find contiguous zeros.
Parameters
bm &BitMap- The
BitMap instance used by this call (borrow).
count usize- count (usize)
Returns
isize — a value of this type
($&BitMap) alloc_contiguous
pub fn (bm $&BitMap) alloc_contiguous(count usize) isize
Purpose
Operation on $&BitMap: alloc contiguous.
Parameters
bm $&BitMap- The
BitMap instance used by this call (exclusive borrow).
count usize- count (usize)
Returns
isize — a value of this type
struct RingBufU8
pub struct RingBufU8 {
pub buf *raw u8
pub cap usize
pub head usize
pub tail usize
pub count usize
}
Purpose
Structure encapsulating buf, cap, head, tail, count.
Public fields
buf *raw u8- buffer
cap usize- field (usize)
head usize- field (usize)
tail usize- field (usize)
count usize- field (usize)
ringbuf_u8_init
pub fn ringbuf_u8_init(rb *raw RingBufU8, buf *raw u8, cap usize)
Purpose
Ringbuf u8 init.
Parameters
rb *raw RingBufU8- rb (*raw RingBufU8)
buf *raw u8- buffer (*raw u8)
cap usize- cap (usize)
Returns
This call does not return a value.
(&RingBufU8) is_empty
pub fn (rb &RingBufU8) is_empty() bool
Purpose
Operation on &RingBufU8: whether it is empty.
Parameters
rb &RingBufU8- The
RingBufU8 instance used by this call (borrow).
Returns
bool — true or false
(&RingBufU8) is_full
pub fn (rb &RingBufU8) is_full() bool
Purpose
Operation on &RingBufU8: whether it is full.
Parameters
rb &RingBufU8- The
RingBufU8 instance used by this call (borrow).
Returns
bool — true or false
(&RingBufU8) len
pub fn (rb &RingBufU8) len() usize
Purpose
Operation on &RingBufU8: return the length.
Parameters
rb &RingBufU8- The
RingBufU8 instance used by this call (borrow).
Returns
usize — a value of this type
($&RingBufU8) push
pub fn (rb $&RingBufU8) push(b u8) bool
Purpose
Execute push on $&RingBufU8.
Parameters
rb $&RingBufU8- The
RingBufU8 instance used by this call (exclusive borrow).
b u8- b (u8)
Returns
bool — true or false
($&RingBufU8) pop
pub fn (rb $&RingBufU8) pop() int
Purpose
Execute pop on $&RingBufU8.
Parameters
rb $&RingBufU8- The
RingBufU8 instance used by this call (exclusive borrow).
Returns
int — a value of this type
struct SpscRingU64
pub struct SpscRingU64 {
pub buf *raw u64
pub mask u64
pub head u64
pub tail u64
}
Purpose
Structure encapsulating buf, mask, head, tail.
Public fields
buf *raw u64- buffer
mask u64- field (u64)
head u64- field (u64)
tail u64- field (u64)
spsc_ring_u64_init
pub fn spsc_ring_u64_init(rb *raw SpscRingU64, buf *raw u64, cap_pow2 usize) bool
Purpose
Spsc ring u64 init.
Parameters
rb *raw SpscRingU64- rb (*raw SpscRingU64)
buf *raw u64- buffer (*raw u64)
cap_pow2 usize- cap_pow2 (usize)
Returns
bool — true or false
(&SpscRingU64) len
pub fn (rb &SpscRingU64) len() u64
Purpose
Operation on &SpscRingU64: return the length.
Parameters
rb &SpscRingU64- The
SpscRingU64 instance used by this call (borrow).
Returns
u64 — a value of this type
(&SpscRingU64) is_empty
pub fn (rb &SpscRingU64) is_empty() bool
Purpose
Operation on &SpscRingU64: whether it is empty.
Parameters
rb &SpscRingU64- The
SpscRingU64 instance used by this call (borrow).
Returns
bool — true or false
(&SpscRingU64) is_full
pub fn (rb &SpscRingU64) is_full() bool
Purpose
Operation on &SpscRingU64: whether it is full.
Parameters
rb &SpscRingU64- The
SpscRingU64 instance used by this call (borrow).
Returns
bool — true or false
($&SpscRingU64) push
pub fn (rb $&SpscRingU64) push(v u64) bool
Purpose
Execute push on $&SpscRingU64.
Parameters
rb $&SpscRingU64- The
SpscRingU64 instance used by this call (exclusive borrow).
v u64- value (u64)
Returns
bool — true or false
($&SpscRingU64) pop
pub fn (rb $&SpscRingU64) pop(out *raw u64) bool
Purpose
Execute pop on $&SpscRingU64.
Parameters
rb $&SpscRingU64- The
SpscRingU64 instance used by this call (exclusive borrow).
out *raw u64- out (*raw u64)
Returns
bool — true or false
struct HeapEntryU64
pub struct HeapEntryU64 {
pub key u64
pub val u64
}
Purpose
Structure encapsulating key, val.
Public fields
key u64- key
val u64- value
struct MinHeapU64
pub struct MinHeapU64 {
pub entries *raw HeapEntryU64
pub cap usize
pub len usize
}
Purpose
Structure encapsulating entries, cap, len.
Public fields
entries *raw HeapEntryU64- field (*raw HeapEntryU64)
cap usize- field (usize)
len usize- field (usize)
min_heap_u64_init
pub fn min_heap_u64_init(h *raw MinHeapU64, entries *raw HeapEntryU64, cap usize) bool
Purpose
Min heap u64 init.
Parameters
h *raw MinHeapU64- height or handle (*raw MinHeapU64)
entries *raw HeapEntryU64- entries (*raw HeapEntryU64)
cap usize- cap (usize)
Returns
bool — true or false
(&MinHeapU64) is_empty
pub fn (h &MinHeapU64) is_empty() bool
Purpose
Operation on &MinHeapU64: whether it is empty.
Parameters
h &MinHeapU64- The
MinHeapU64 instance used by this call (borrow).
Returns
bool — true or false
(&MinHeapU64) peek
pub fn (h &MinHeapU64) peek(out_key *raw u64, out_val *raw u64) bool
Purpose
Execute peek on &MinHeapU64.
Parameters
h &MinHeapU64- The
MinHeapU64 instance used by this call (borrow).
out_key *raw u64- out_key (*raw u64)
out_val *raw u64- out_val (*raw u64)
Returns
bool — true or false
($&MinHeapU64) push
pub fn (h $&MinHeapU64) push(key u64, val u64) bool
Purpose
Execute push on $&MinHeapU64.
Parameters
h $&MinHeapU64- The
MinHeapU64 instance used by this call (exclusive borrow).
key u64- key (u64)
val u64- value (u64)
Returns
bool — true or false
($&MinHeapU64) pop
pub fn (h $&MinHeapU64) pop(out_key *raw u64, out_val *raw u64) bool
Purpose
Execute pop on $&MinHeapU64.
Parameters
h $&MinHeapU64- The
MinHeapU64 instance used by this call (exclusive borrow).
out_key *raw u64- out_key (*raw u64)
out_val *raw u64- out_val (*raw u64)
Returns
bool — true or false