Add __fseterr and __freadahead to stdio ext (P3-stdio-fseterr patch)
This commit is contained in:
@@ -3,4 +3,20 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
size_t __freadahead(FILE *stream);
|
||||||
|
size_t __fpending(FILE *stream);
|
||||||
|
int __freadable(FILE *stream);
|
||||||
|
int __freading(FILE *stream);
|
||||||
|
void __fseterr(FILE *stream);
|
||||||
|
int __fwritable(FILE *stream);
|
||||||
|
int __fwriting(FILE *stream);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
} // extern "C"
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* _STDIO_EXT_H */
|
#endif /* _STDIO_EXT_H */
|
||||||
|
|||||||
+15
-1
@@ -1,8 +1,15 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
header::stdio::{F_NORD, F_NOWR, FILE},
|
header::stdio::{F_ERR, F_NORD, F_NOWR, FILE},
|
||||||
platform::types::{c_int, size_t},
|
platform::types::{c_int, size_t},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#[unsafe(no_mangle)]
|
||||||
|
pub extern "C" fn __freadahead(stream: *mut FILE) -> size_t {
|
||||||
|
let stream = unsafe { &mut *stream }.lock();
|
||||||
|
|
||||||
|
(stream.read_size.saturating_sub(stream.read_pos) + stream.unget.len()) as size_t
|
||||||
|
}
|
||||||
|
|
||||||
#[unsafe(no_mangle)]
|
#[unsafe(no_mangle)]
|
||||||
pub extern "C" fn __fpending(stream: *mut FILE) -> size_t {
|
pub extern "C" fn __fpending(stream: *mut FILE) -> size_t {
|
||||||
let stream = unsafe { &mut *stream }.lock();
|
let stream = unsafe { &mut *stream }.lock();
|
||||||
@@ -24,6 +31,13 @@ pub extern "C" fn __fwritable(stream: *mut FILE) -> c_int {
|
|||||||
c_int::from(stream.flags & F_NOWR == 0)
|
c_int::from(stream.flags & F_NOWR == 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[unsafe(no_mangle)]
|
||||||
|
pub extern "C" fn __fseterr(stream: *mut FILE) {
|
||||||
|
let mut stream = unsafe { &mut *stream }.lock();
|
||||||
|
|
||||||
|
stream.flags |= F_ERR;
|
||||||
|
}
|
||||||
|
|
||||||
//TODO: Check last operation when read-write
|
//TODO: Check last operation when read-write
|
||||||
#[unsafe(no_mangle)]
|
#[unsafe(no_mangle)]
|
||||||
pub extern "C" fn __freading(stream: *mut FILE) -> c_int {
|
pub extern "C" fn __freading(stream: *mut FILE) -> c_int {
|
||||||
|
|||||||
Reference in New Issue
Block a user