Closed VocalFan closed 5 months ago
And if you're confused why 5, 7, and 11 were added:
case CLOCK_MONOTONIC: /* Default to precise. */
case CLOCK_MONOTONIC_PRECISE:
case CLOCK_UPTIME:
case CLOCK_UPTIME_PRECISE:
nanouptime(ats);
They all use nanouptime
The commit above was done so that we can have all the clock values defined. Also helps us see what clock_id it errors on now.
++++++++++++++++++ I [00:00:00:00:780]:0x0000000000009fe8: kernel\src\time\mod.rs:47
Getting clock time with clock_id = SonyUnk1
++++++++++++++++++ P [00:00:00:00:780]:0x0000000000009fe8: kernel\src\time\mod.rs:66
not yet implemented
And evidence so @ultimaweapon Knows I actually looked at stuff lol:
/* These macros are also in sys/time.h. */
#if !defined(CLOCK_REALTIME) && __POSIX_VISIBLE >= 200112
#define CLOCK_REALTIME 0
#ifdef __BSD_VISIBLE
#define CLOCK_VIRTUAL 1
#define CLOCK_PROF 2
#endif
#define CLOCK_MONOTONIC 4
#define CLOCK_UPTIME 5 /* FreeBSD-specific. */
#define CLOCK_UPTIME_PRECISE 7 /* FreeBSD-specific. */
#define CLOCK_UPTIME_FAST 8 /* FreeBSD-specific. */
#define CLOCK_REALTIME_PRECISE 9 /* FreeBSD-specific. */
#define CLOCK_REALTIME_FAST 10 /* FreeBSD-specific. */
#define CLOCK_MONOTONIC_PRECISE 11 /* FreeBSD-specific. */
#define CLOCK_MONOTONIC_FAST 12 /* FreeBSD-specific. */
#define CLOCK_SECOND 13 /* FreeBSD-specific. */
#define CLOCK_THREAD_CPUTIME_ID 14
#endif
switch (clock_id) {
case CLOCK_REALTIME: /* Default to precise. */
case CLOCK_REALTIME_PRECISE:
nanotime(ats);
break;
case CLOCK_REALTIME_FAST:
getnanotime(ats);
break;
case CLOCK_VIRTUAL:
PROC_LOCK(p);
PROC_SLOCK(p);
calcru(p, &user, &sys);
PROC_SUNLOCK(p);
PROC_UNLOCK(p);
TIMEVAL_TO_TIMESPEC(&user, ats);
break;
case CLOCK_PROF:
PROC_LOCK(p);
PROC_SLOCK(p);
calcru(p, &user, &sys);
PROC_SUNLOCK(p);
PROC_UNLOCK(p);
timevaladd(&user, &sys);
TIMEVAL_TO_TIMESPEC(&user, ats);
break;
case CLOCK_MONOTONIC: /* Default to precise. */
case CLOCK_MONOTONIC_PRECISE:
case CLOCK_UPTIME:
case CLOCK_UPTIME_PRECISE:
nanouptime(ats);
break;
case CLOCK_UPTIME_FAST:
case CLOCK_MONOTONIC_FAST:
getnanouptime(ats);
break;
case CLOCK_SECOND:
ats->tv_sec = time_second;
ats->tv_nsec = 0;
break;
case CLOCK_THREAD_CPUTIME_ID:
critical_enter();
switchtime = PCPU_GET(switchtime);
curtime = cpu_ticks();
runtime = td->td_runtime;
critical_exit();
runtime = cputick2usec(runtime + curtime - switchtime);
ats->tv_sec = runtime / 1000000;
ats->tv_nsec = runtime % 1000000 * 1000;
break;
default:
return (EINVAL);
}
FREEBSD SOURCE CODE ^
case 15:
nanouptime(a1);
v20 = *v7 - *(_QWORD *)(_R15 + 2648);
*v7 = v20;
LODWORD(v8) = 0;
v21 = v7[1] - *(_QWORD *)(_R15 + 2656);
v7[1] = v21;
if ( v21 < 0 )
{
*v7 = v20 - 1;
v7[1] = v21 + 1000000000;
}
break;
case 16:
if ( (*(_QWORD *)(a2[38] + 88LL) & 0xF00000000000000LL) != 0x100000000000000LL )
goto LABEL_27;
goto LABEL_26;
case 17:
if ( !(unsigned int)sceSblACMgrIsSystemUcred(a2[38]) )
break;
goto LABEL_26;
case 18:
if ( !(unsigned int)sceSblACMgrIsSystemUcred(a2[38]) )
break;
LOBYTE(v22) = sceSblRcMgrIsAllowAdClock();
if ( !v22 )
goto LABEL_27;
LABEL_26:
v8 = 0LL;
if ( (unsigned int)get_extra_clock(22LL, 1, (__int64)v7, a4, a5, (__int64)a2, a6, a7) )
goto LABEL_27;
break;
case 19:
LABEL_27:
LODWORD(v8) = get_extra_clock(v8, 0, (__int64)v7, a4, a5, (__int64)a2, a6, a7);
break;
default:
Sony specific ^
Implements Nanouptime for windows as that was missing, along with implementing 13 (seconds) for both platforms.