@@ -72,7 +72,7 @@ impl FileDescription for Event {
7272 // Check the size of slice, and return error only if the size of the slice < 8.
7373 if len < U64_ARRAY_SIZE . try_into ( ) . unwrap ( ) {
7474 let result = Err ( Error :: from ( ErrorKind :: InvalidInput ) ) ;
75- read_byte_helper_ev ( & buf_place, None , result, dest, ecx) ?;
75+ return_read_bytes_and_count_ev ( & buf_place, None , result, dest, ecx) ?;
7676 return Ok ( ( ) ) ;
7777 }
7878
@@ -81,7 +81,7 @@ impl FileDescription for Event {
8181 if counter == 0 {
8282 if self . is_nonblock {
8383 let result = Err ( Error :: from ( ErrorKind :: WouldBlock ) ) ;
84- read_byte_helper_ev ( & buf_place, None , result, dest, ecx) ?;
84+ return_read_bytes_and_count_ev ( & buf_place, None , result, dest, ecx) ?;
8585 return Ok ( ( ) ) ;
8686 } else {
8787 //FIXME: blocking is not supported
@@ -91,7 +91,7 @@ impl FileDescription for Event {
9191 // Synchronize with all prior `write` calls to this FD.
9292 ecx. acquire_clock ( & self . clock . borrow ( ) ) ;
9393 let result = Ok ( U64_ARRAY_SIZE ) ;
94- read_byte_helper_ev ( & buf_place, Some ( counter) , result, dest, ecx) ?;
94+ return_read_bytes_and_count_ev ( & buf_place, Some ( counter) , result, dest, ecx) ?;
9595 self . counter . set ( 0 ) ;
9696 // When any of the event happened, we check and update the status of all supported event
9797 // types for current file description.
@@ -124,7 +124,7 @@ impl FileDescription for Event {
124124 // Check the size of slice, and return error only if the size of the slice < 8.
125125 let Some ( bytes) = bytes. first_chunk :: < U64_ARRAY_SIZE > ( ) else {
126126 let result = Err ( Error :: from ( ErrorKind :: InvalidInput ) ) ;
127- ecx. write_byte_helper ( result, dest) ?;
127+ ecx. return_written_byte_count_or_error ( result, dest) ?;
128128 return Ok ( ( ) ) ;
129129 } ;
130130 // Convert from bytes to int according to host endianness.
@@ -135,7 +135,7 @@ impl FileDescription for Event {
135135 // u64::MAX as input is invalid because the maximum value of counter is u64::MAX - 1.
136136 if num == u64:: MAX {
137137 let result = Err ( Error :: from ( ErrorKind :: InvalidInput ) ) ;
138- ecx. write_byte_helper ( result, dest) ?;
138+ ecx. return_written_byte_count_or_error ( result, dest) ?;
139139 return Ok ( ( ) ) ;
140140 }
141141 // If the addition does not let the counter to exceed the maximum value, update the counter.
@@ -151,7 +151,7 @@ impl FileDescription for Event {
151151 None | Some ( u64:: MAX ) => {
152152 if self . is_nonblock {
153153 let result = Err ( Error :: from ( ErrorKind :: WouldBlock ) ) ;
154- ecx. write_byte_helper ( result, dest) ?;
154+ ecx. return_written_byte_count_or_error ( result, dest) ?;
155155 return Ok ( ( ) ) ;
156156 } else {
157157 //FIXME: blocking is not supported
@@ -164,7 +164,7 @@ impl FileDescription for Event {
164164 ecx. check_and_update_readiness ( self_ref) ?;
165165
166166 let result = Ok ( U64_ARRAY_SIZE ) ;
167- ecx. write_byte_helper ( result, dest) ?;
167+ ecx. return_written_byte_count_or_error ( result, dest) ?;
168168 Ok ( ( ) )
169169 }
170170}
@@ -231,8 +231,9 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
231231 }
232232}
233233
234- /// This function either writes to the user supplied buffer and to dest place, or return error.
235- fn read_byte_helper_ev < ' tcx > (
234+ /// This function either writes to the user supplied buffer and to dest place, or sets the
235+ /// last libc error and writes -1 to dest. This is only used by eventfd.
236+ fn return_read_bytes_and_count_ev < ' tcx > (
236237 buf_place : & MPlaceTy < ' tcx > ,
237238 read_val : Option < u64 > ,
238239 result : io:: Result < usize > ,
0 commit comments