gnu_libjit/label.rs
1use gnu_libjit_sys::{jit_label_t};
2
3pub struct Label {
4 pub(crate) inner: jit_label_t,
5}
6impl Label {
7 // Creates a new label that undefined. Will not be placed into into
8 // the function until function.insn_label is called. You may use this as a branch
9 // target before placing it.
10 pub fn new() -> Label {
11 let value: ::std::os::raw::c_ulong = 1;
12 let mut bytes = value.to_le_bytes();
13 for i in 0..4 {
14 bytes[i] = 0xFF; // TODO: is jit_undefined_label 2^32-1 on all systems?
15 }
16 let value = ::std::os::raw::c_ulong::from_le_bytes(bytes);
17 Label {
18 inner: value
19 }
20 }
21}