#![allow(missing_docs)]

use abi::error::Error;

pub fn get_thread_pointer() -> usize {
    let output: usize;
    unsafe { core::arch::asm!("mv {0}, tp", out(reg) output) };
    output
}

/// Writes `value` into `tp` register.
///
/// # Safety
///
/// Usual pointer rules apply.
pub unsafe fn set_thread_pointer(value: usize) -> Result<(), Error> {
    core::arch::asm!("mv tp, {0}", in(reg) value);
    Ok(())
}
