| 361 | } |
| 362 | |
| 363 | static int timerfd_do_settime(int fd, int flags, const struct itimerspec *new, struct itimerspec *old) |
| 364 | { |
| 365 | int ret = 0; |
| 366 | struct rt_timerfd *tfd; |
| 367 | struct dfs_file *df; |
| 368 | struct timespec current_time; |
| 369 | int tick_out; |
| 370 | rt_int64_t value_msec; |
| 371 | rt_int64_t interval_msec; |
| 372 | rt_int64_t cur_time = 0; |
| 373 | |
| 374 | if (fd < 0) |
| 375 | { |
| 376 | rt_set_errno(EINVAL); |
| 377 | return -EINVAL; |
| 378 | } |
| 379 | |
| 380 | df = fd_get(fd); |
| 381 | if (!df) |
| 382 | return -EINVAL; |
| 383 | |
| 384 | tfd = df->vnode->data; |
| 385 | |
| 386 | rt_atomic_store(&(tfd->ticks), 0); |
| 387 | rt_atomic_store(&(tfd->timeout_num), 0); |
| 388 | |
| 389 | rt_mutex_take(&tfd->lock, RT_WAITING_FOREVER); |
| 390 | tfd->isperiodic = INIT_PERIODIC; |
| 391 | |
| 392 | if (old) |
| 393 | { |
| 394 | old->it_interval.tv_nsec = tfd->ittimer.it_interval.tv_nsec; |
| 395 | old->it_interval.tv_sec = tfd->ittimer.it_interval.tv_sec; |
| 396 | old->it_value.tv_nsec = tfd->ittimer.it_value.tv_nsec; |
| 397 | old->it_value.tv_sec = tfd->ittimer.it_value.tv_sec; |
| 398 | } |
| 399 | |
| 400 | if (new) |
| 401 | { |
| 402 | if (tfd->timer != RT_NULL) |
| 403 | { |
| 404 | rt_timer_stop(tfd->timer); |
| 405 | rt_timer_delete(tfd->timer); |
| 406 | tfd->timer = RT_NULL; |
| 407 | } |
| 408 | |
| 409 | if (new->it_value.tv_nsec == 0 && new->it_value.tv_sec == 0) |
| 410 | { |
| 411 | rt_mutex_release(&tfd->lock); |
| 412 | return 0; |
| 413 | } |
| 414 | |
| 415 | value_msec = (new->it_value.tv_nsec / MSEC_TO_NSEC) + (new->it_value.tv_sec * SEC_TO_MSEC); |
| 416 | interval_msec = (new->it_interval.tv_nsec / MSEC_TO_NSEC) + (new->it_interval.tv_sec * SEC_TO_MSEC); |
| 417 | |
| 418 | current_time.tv_nsec = 0; |
| 419 | current_time.tv_sec = 0; |
| 420 |
no test coverage detected