Changeset 87822ce in mainline for uspace/lib/c/generic/io/console.c
- Timestamp:
- 2021-03-04T19:14:30Z (4 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- d6c4d40
- Parents:
- 760a392
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/io/console.c
r760a392 r87822ce 180 180 } 181 181 182 bool console_get_event(console_ctrl_t *ctrl, cons_event_t *event) 182 /** Get console event. 183 * 184 * @param ctrl Console 185 * @param event Place to store event 186 * @return EOK on success, EIO on failure 187 */ 188 errno_t console_get_event(console_ctrl_t *ctrl, cons_event_t *event) 183 189 { 184 190 if (ctrl->input_aid == 0) { … … 192 198 async_wait_for(aid, &rc); 193 199 194 if (rc != EOK) { 195 errno = rc; 196 return false; 197 } 200 if (rc != EOK) 201 return EIO; 198 202 199 203 rc = console_ev_decode(&result, event); 200 if (rc != EOK) { 201 errno = rc; 202 return false; 203 } 204 if (rc != EOK) 205 return EIO; 204 206 } else { 205 207 errno_t retval; … … 208 210 ctrl->input_aid = 0; 209 211 210 if (retval != EOK) { 211 errno = retval; 212 return false; 213 } 212 if (retval != EOK) 213 return EIO; 214 214 215 215 errno_t rc = console_ev_decode(&ctrl->input_call, event); 216 if (rc != EOK) { 217 errno = rc; 218 return false; 219 } 220 } 221 222 return true; 223 } 224 225 bool console_get_event_timeout(console_ctrl_t *ctrl, cons_event_t *event, 216 if (rc != EOK) 217 return EIO; 218 } 219 220 return EOK; 221 } 222 223 /** Get console event with timeout. 224 * 225 * @param ctrl Console 226 * @param event Place to store event 227 * @param timeout Pointer to timeout. This will be updated to reflect 228 * the remaining time in case of timeout. 229 * @return EOK on success (event received), ETIMEOUT on time out, 230 * EIO on I/O error (e.g. lost console connection), ENOMEM 231 * if out of memory 232 */ 233 errno_t console_get_event_timeout(console_ctrl_t *ctrl, cons_event_t *event, 226 234 usec_t *timeout) 227 235 { … … 239 247 errno_t rc = async_wait_timeout(ctrl->input_aid, &retval, *timeout); 240 248 if (rc != EOK) { 249 if (rc == ENOMEM) 250 return ENOMEM; 241 251 *timeout = 0; 242 errno = rc; 243 return false; 252 return ETIMEOUT; 244 253 } 245 254 246 255 ctrl->input_aid = 0; 247 256 248 if (retval != EOK) { 249 errno = retval; 250 return false; 251 } 257 if (retval != EOK) 258 return EIO; 252 259 253 260 rc = console_ev_decode(&ctrl->input_call, event); 254 if (rc != EOK) { 255 errno = rc; 256 return false; 257 } 261 if (rc != EOK) 262 return EIO; 258 263 259 264 /* Update timeout */ … … 262 267 *timeout -= NSEC2USEC(ts_sub_diff(&t1, &t0)); 263 268 264 return true;269 return EOK; 265 270 } 266 271
Note:
See TracChangeset
for help on using the changeset viewer.