<commit_before>//! System primitives.

use core::ptr::Unique;

use fail;

/// Out of memory.
///
/// In release mode, this will simply abort the process (standard behavior). In debug mode, it will
/// panic, causing debugging to be easier.
pub fn oom() -> ! {
    fail::oom();
}

/// A system call error.
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub enum Error {
    /// Sir, we're running outta memory!
    OutOfMemory,
    /// Arithmetic overflow.
    ArithOverflow,
    /// An unknown error occurred.
    Unknown,
}

impl Error {
    /// Handle this error with the appropriate method.
    pub fn handle(self) -> ! {
        match self {
            Error::OutOfMemory | Error::ArithOverflow => oom(),
            Error::Unknown => panic!("Unknown OS error.")
        }
    }
}

/// Cooperatively gives up a timeslice to the OS scheduler.
pub fn yield_now() {
    unsafe {
        #[cfg(unix)]
        syscall!(SCHED_YIELD);

        #[cfg(redox)]
        ::system::syscall::unix::sys_yield();
    }
}

/// Retrieve the end of the current data segment.
///
/// This will not change the state of the process in any way, and is thus safe.
pub fn segment_end() -> Result<*const u8, Error> {<commit_msg>Fix cfg flags for Redox<commit_after>//! System primitives.

use core::ptr::Unique;

use fail;

/// Out of memory.
///
/// In release mode, this will simply abort the process (standard behavior). In debug mode, it will
/// panic, causing debugging to be easier.
pub fn oom() -> ! {
    fail::oom();
}

/// A system call error.
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub enum Error {
    /// Sir, we're running outta memory!
    OutOfMemory,
    /// Arithmetic overflow.
    ArithOverflow,
    /// An unknown error occurred.
    Unknown,
}

impl Error {
    /// Handle this error with the appropriate method.
    pub fn handle(self) -> ! {
        match self {
            Error::OutOfMemory | Error::ArithOverflow => oom(),
            Error::Unknown => panic!("Unknown OS error.")
        }
    }
}

/// Cooperatively gives up a timeslice to the OS scheduler.
pub fn yield_now() {
    unsafe {
        #[cfg(not(target_os = "redox"))]
        syscall!(SCHED_YIELD);

        #[cfg(target_os = "redox")]
        ::system::syscall::unix::sys_yield();
    }
}

/// Retrieve the end of the current data segment.
///
/// This will not change the state of the process in any way, and is thus safe.
pub fn segment_end() -> Result<*const u8, Error> {
{'fraction_non_alphanumeric': 0.1401792991035045, 'fraction_numerical': 0.0008149959250203749, 'mean_word_length': 2.4724186704384725, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '442109', 'n_tokens_mistral': 755, 'n_tokens_neox': 740, 'n_words': 266}