diff --git a/src/stdio/src/default.rs b/src/stdio/src/default.rs index 8ba56533de089ff597006e1b3f70b2b481f121da..efeb05c9a476a5b7c9f52cc6638da1be711a90ca 100644 --- a/src/stdio/src/default.rs +++ b/src/stdio/src/default.rs @@ -20,7 +20,7 @@ static mut default_stdin: FILE = FILE { unget: UNGET, lock: AtomicBool::new(false), write: None, - read: Some(&internal::stdio_read), + read: Some(internal::stdio_read), seek: None, }; @@ -41,7 +41,7 @@ static mut default_stdout: FILE = FILE { buf_char: b'\n' as i8, unget: 0, lock: AtomicBool::new(false), - write: Some(&internal::stdio_write), + write: Some(internal::stdio_write), read: None, seek: None, }; @@ -63,7 +63,7 @@ static mut default_stderr: FILE = FILE { buf_char: -1, unget: 0, lock: AtomicBool::new(false), - write: Some(&internal::stdio_write), + write: Some(internal::stdio_write), read: None, seek: None, }; diff --git a/src/stdio/src/helpers.rs b/src/stdio/src/helpers.rs index 267d49da3928f65f54de0cc945af2ce00b803a3d..5342490269ad4bb46493d875fa4b8f539dfb938f 100644 --- a/src/stdio/src/helpers.rs +++ b/src/stdio/src/helpers.rs @@ -78,9 +78,9 @@ pub unsafe fn _fdopen(fd: c_int, mode: *const c_char) -> *mut FILE { buf_char: -1, unget: UNGET, lock: AtomicBool::new(false), - write: Some(&internal::stdio_write), - read: Some(&internal::stdio_read), - seek: Some(&internal::stdio_seek), + write: Some(internal::stdio_write), + read: Some(internal::stdio_read), + seek: Some(internal::stdio_seek), }; file } @@ -97,7 +97,7 @@ pub unsafe fn fwritex(buf: *const u8, l: size_t, stream: *mut FILE) -> size_t { } if l > (*stream).wend as usize - (*stream).wpos as usize { // We can't fit all of buf in the buffer - return (*stream_write)(stream, buf, l); + return stream_write(stream, buf, l); } let i = if (*stream).buf_char >= 0 { @@ -106,7 +106,7 @@ pub unsafe fn fwritex(buf: *const u8, l: size_t, stream: *mut FILE) -> size_t { i -= 1; } if i > 0 { - let n = (*stream_write)(stream, buf, i); + let n = stream_write(stream, buf, i); if n < i { return n; } @@ -131,7 +131,7 @@ pub unsafe fn fwritex(buf: *const u8, l: size_t, stream: *mut FILE) -> size_t { pub unsafe fn fflush_unlocked(stream: *mut FILE) -> c_int { if (*stream).wpos > (*stream).wbase { if let Some(f) = (*stream).write { - (*f)(stream, ptr::null(), 0); + f(stream, ptr::null(), 0); if (*stream).wpos.is_null() { return -1; } @@ -142,7 +142,7 @@ pub unsafe fn fflush_unlocked(stream: *mut FILE) -> c_int { if (*stream).rpos < (*stream).rend { if let Some(s) = (*stream).seek { - (*s)( + s( stream, (*stream).rpos as i64 - (*stream).rend as i64, SEEK_CUR, diff --git a/src/stdio/src/internal.rs b/src/stdio/src/internal.rs index f9ef756f64eb67d796c46c1fa203818cd0716eee..99005e87a6ad22199801940dc29e443115039343 100644 --- a/src/stdio/src/internal.rs +++ b/src/stdio/src/internal.rs @@ -83,7 +83,7 @@ pub unsafe fn to_read(stream: *mut FILE) -> bool { if (*stream).wpos > (*stream).wbase { if let Some(f) = (*stream).write { - (*f)(stream, ptr::null(), 0); + f(stream, ptr::null(), 0); } } (*stream).wpos = ptr::null_mut(); @@ -123,7 +123,7 @@ pub unsafe fn to_write(stream: *mut FILE) -> bool { pub unsafe fn ftello(stream: *mut FILE) -> off_t { if let Some(s) = (*stream).seek { - let pos = (*s)( + let pos = s( stream, 0, if ((*stream).flags & constants::F_APP > 0) && (*stream).wpos > (*stream).wbase { diff --git a/src/stdio/src/lib.rs b/src/stdio/src/lib.rs index 8c291ca28181786816ab3425d5984368f80f0ea8..df5e9b6db3751cd07d0cf663dcf614dd49bf00c9 100644 --- a/src/stdio/src/lib.rs +++ b/src/stdio/src/lib.rs @@ -50,9 +50,9 @@ pub struct FILE { buf_char: i8, lock: AtomicBool, unget: size_t, - write: Option<*const (Fn(*mut FILE, *const u8, usize) -> size_t)>, - read: Option<*const (Fn(*mut FILE, *mut u8, usize) -> size_t)>, - seek: Option<*const (Fn(*mut FILE, off_t, c_int) -> off_t)>, + write: Option<(fn(*mut FILE, *const u8, usize) -> size_t)>, + read: Option<(fn(*mut FILE, *mut u8, usize) -> size_t)>, + seek: Option<(fn(*mut FILE, off_t, c_int) -> off_t)>, } /// Clears EOF and ERR indicators on a stream @@ -291,7 +291,7 @@ pub unsafe extern "C" fn fread( 0 } else { if let Some(f) = (*stream).read { - (*f)(stream, dest, l as usize) + f(stream, dest, l as usize) } else { 0 } @@ -378,7 +378,7 @@ pub unsafe extern "C" fn fseeko(stream: *mut FILE, offset: off_t, whence: c_int) } if (*stream).wpos > (*stream).wbase { if let Some(f) = (*stream).write { - (*f)(stream, ptr::null(), 0); + f(stream, ptr::null(), 0); if (*stream).wpos.is_null() { return -1; } @@ -388,7 +388,7 @@ pub unsafe extern "C" fn fseeko(stream: *mut FILE, offset: off_t, whence: c_int) (*stream).wend = ptr::null_mut(); (*stream).wbase = ptr::null_mut(); if let Some(s) = (*stream).seek { - if (*s)(stream, off, whence) < 0 { + if s(stream, off, whence) < 0 { return -1; } } else { @@ -481,7 +481,7 @@ pub unsafe extern "C" fn getc_unlocked(stream: *mut FILE) -> c_int { } else { if let Some(read) = (*stream).read { let mut c = 0u8; - if !internal::to_read(stream) && (*read)(stream, &mut c, 1) == 1 { + if !internal::to_read(stream) && read(stream, &mut c, 1) == 1 { c as c_int } else { -1 @@ -575,7 +575,7 @@ pub unsafe extern "C" fn putc_unlocked(c: c_int, stream: *mut FILE) -> c_int { *(*stream).wpos = c as u8; (*stream).wpos = (*stream).wpos.add(1); c - } else if (*write)(stream, &c as *const i32 as *const _, 1) != 1 { + } else if write(stream, &c as *const i32 as *const _, 1) != 1 { -1 } else { c