02f202ff83
BufWriter has more capacity (8k vs 1k) and doesn't flush the stream after '\n'. That change helps to reduce the number of syscalls, especially when dealing with text files. Since BufWriter has a different way of getting number of pending elements than LineWriter - Pending trait was introduced to deal with that.
42 lines
997 B
Rust
42 lines
997 B
Rust
use crate::{
|
|
header::stdio::{FILE, F_NORD, F_NOWR},
|
|
platform::types::*,
|
|
};
|
|
|
|
#[no_mangle]
|
|
pub extern "C" fn __fpending(stream: *mut FILE) -> size_t {
|
|
let stream = unsafe { &mut *stream }.lock();
|
|
|
|
stream.writer.pending()
|
|
}
|
|
|
|
#[no_mangle]
|
|
pub extern "C" fn __freadable(stream: *mut FILE) -> c_int {
|
|
let stream = unsafe { &mut *stream }.lock();
|
|
|
|
(stream.flags & F_NORD == 0) as c_int
|
|
}
|
|
|
|
#[no_mangle]
|
|
pub extern "C" fn __fwritable(stream: *mut FILE) -> c_int {
|
|
let stream = unsafe { &mut *stream }.lock();
|
|
|
|
(stream.flags & F_NOWR == 0) as c_int
|
|
}
|
|
|
|
//TODO: Check last operation when read-write
|
|
#[no_mangle]
|
|
pub extern "C" fn __freading(stream: *mut FILE) -> c_int {
|
|
let stream = unsafe { &mut *stream }.lock();
|
|
|
|
(stream.flags & F_NORD == 0) as c_int
|
|
}
|
|
|
|
//TODO: Check last operation when read-write
|
|
#[no_mangle]
|
|
pub extern "C" fn __fwriting(stream: *mut FILE) -> c_int {
|
|
let stream = unsafe { &mut *stream }.lock();
|
|
|
|
(stream.flags & F_NOWR == 0) as c_int
|
|
}
|