MCPcopy Create free account
hub / github.com/danoon2/Boxedwine / timerfd_gettime

Method timerfd_gettime

source/kernel/kprocess.cpp:2591–2624  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2589}
2590
2591U32 KProcess::timerfd_gettime(U32 fildes, U32 value) {
2592 KFileDescriptorPtr fd = getFileDescriptor(fildes);
2593 if (!fd) {
2594 return -K_EBADF;
2595 }
2596 if (fd->kobject->type != KTYPE_SIGNAL) {
2597 return -K_EINVAL;
2598 }
2599 if (!value) {
2600 return -K_EFAULT;
2601 }
2602 std::shared_ptr<KTimer> timer = std::dynamic_pointer_cast<KTimer>(fd->kobject);
2603 U64 microNextTimer = timer->getMicroNextTimer();
2604 U64 microInterval = timer->getMicroInterval();
2605
2606 memory->writed(value, (U32)(microInterval / 1000000));
2607 memory->writed(value + 4, (U32)((microInterval % 1000000) * 1000));
2608
2609 if (!microNextTimer) {
2610 memory->writed(value + 8, 0);
2611 memory->writed(value + 12, 0);
2612 } else {
2613 U64 currentTime = KSystem::getSystemTimeAsMicroSeconds();
2614 S64 diff = (S64)microNextTimer - (S64)currentTime;
2615 if (diff < 0) {
2616 memory->writed(value + 8, 0);
2617 memory->writed(value + 12, 0);
2618 } else {
2619 memory->writed(value + 8, (U32)(diff / 1000000));
2620 memory->writed(value + 12, (diff % 1000000) * 1000);
2621 }
2622 }
2623 return 0;
2624}
2625
2626user_desc* KProcess::getLDT(U32 index) {
2627 BOXEDWINE_CRITICAL_SECTION_WITH_MUTEX(ldtMutex);

Callers 1

syscall_timerfd_gettimeFunction · 0.80

Calls 3

getMicroNextTimerMethod · 0.80
getMicroIntervalMethod · 0.80
writedMethod · 0.45

Tested by

no test coverage detected