@@ -72,7 +72,7 @@ impl FileDescription for Event {
72
72
// Check the size of slice, and return error only if the size of the slice < 8.
73
73
if len < U64_ARRAY_SIZE . try_into ( ) . unwrap ( ) {
74
74
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) ?;
76
76
return Ok ( ( ) ) ;
77
77
}
78
78
@@ -81,7 +81,7 @@ impl FileDescription for Event {
81
81
if counter == 0 {
82
82
if self . is_nonblock {
83
83
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) ?;
85
85
return Ok ( ( ) ) ;
86
86
} else {
87
87
//FIXME: blocking is not supported
@@ -91,7 +91,7 @@ impl FileDescription for Event {
91
91
// Synchronize with all prior `write` calls to this FD.
92
92
ecx. acquire_clock ( & self . clock . borrow ( ) ) ;
93
93
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) ?;
95
95
self . counter . set ( 0 ) ;
96
96
// When any of the event happened, we check and update the status of all supported event
97
97
// types for current file description.
@@ -124,7 +124,7 @@ impl FileDescription for Event {
124
124
// Check the size of slice, and return error only if the size of the slice < 8.
125
125
let Some ( bytes) = bytes. first_chunk :: < U64_ARRAY_SIZE > ( ) else {
126
126
let result = Err ( Error :: from ( ErrorKind :: InvalidInput ) ) ;
127
- ecx. write_byte_helper ( result, dest) ?;
127
+ ecx. return_written_byte_count_or_error ( result, dest) ?;
128
128
return Ok ( ( ) ) ;
129
129
} ;
130
130
// Convert from bytes to int according to host endianness.
@@ -135,7 +135,7 @@ impl FileDescription for Event {
135
135
// u64::MAX as input is invalid because the maximum value of counter is u64::MAX - 1.
136
136
if num == u64:: MAX {
137
137
let result = Err ( Error :: from ( ErrorKind :: InvalidInput ) ) ;
138
- ecx. write_byte_helper ( result, dest) ?;
138
+ ecx. return_written_byte_count_or_error ( result, dest) ?;
139
139
return Ok ( ( ) ) ;
140
140
}
141
141
// If the addition does not let the counter to exceed the maximum value, update the counter.
@@ -151,7 +151,7 @@ impl FileDescription for Event {
151
151
None | Some ( u64:: MAX ) => {
152
152
if self . is_nonblock {
153
153
let result = Err ( Error :: from ( ErrorKind :: WouldBlock ) ) ;
154
- ecx. write_byte_helper ( result, dest) ?;
154
+ ecx. return_written_byte_count_or_error ( result, dest) ?;
155
155
return Ok ( ( ) ) ;
156
156
} else {
157
157
//FIXME: blocking is not supported
@@ -164,7 +164,7 @@ impl FileDescription for Event {
164
164
ecx. check_and_update_readiness ( self_ref) ?;
165
165
166
166
let result = Ok ( U64_ARRAY_SIZE ) ;
167
- ecx. write_byte_helper ( result, dest) ?;
167
+ ecx. return_written_byte_count_or_error ( result, dest) ?;
168
168
Ok ( ( ) )
169
169
}
170
170
}
@@ -231,8 +231,9 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
231
231
}
232
232
}
233
233
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 > (
236
237
buf_place : & MPlaceTy < ' tcx > ,
237
238
read_val : Option < u64 > ,
238
239
result : io:: Result < usize > ,
0 commit comments