mirror of
https://github.com/RPCSX/rpcsx.git
synced 2026-03-06 05:24:03 +01:00
[orbis-kernel] Fix sys_gettimeofday
This commit is contained in:
parent
24d8a8ae8e
commit
14b41d1af9
|
|
@ -11,15 +11,8 @@ using cpuwhich_t = sint;
|
|||
using cpulevel_t = sint;
|
||||
using SceKernelModule = ModuleHandle;
|
||||
|
||||
struct timeval {
|
||||
int64_t tv_sec;
|
||||
int64_t tv_usec;
|
||||
};
|
||||
|
||||
struct timezone {
|
||||
sint tz_minuteswest;
|
||||
sint tz_dsttime;
|
||||
};
|
||||
struct timeval;
|
||||
struct timezone;
|
||||
|
||||
struct ModuleInfo;
|
||||
struct ModuleInfoEx;
|
||||
|
|
|
|||
|
|
@ -7,4 +7,12 @@ struct timespec {
|
|||
uint64_t sec;
|
||||
uint64_t nsec;
|
||||
};
|
||||
struct timeval {
|
||||
int64_t tv_sec;
|
||||
int64_t tv_usec;
|
||||
};
|
||||
struct timezone {
|
||||
sint tz_minuteswest;
|
||||
sint tz_dsttime;
|
||||
};
|
||||
} // namespace orbis
|
||||
|
|
|
|||
|
|
@ -114,9 +114,9 @@ orbis::SysResult orbis::sys_nanosleep(Thread *thread, ptr<const timespec> rqtp,
|
|||
}
|
||||
orbis::SysResult orbis::sys_gettimeofday(Thread *thread, ptr<orbis::timeval> tp,
|
||||
ptr<orbis::timezone> tzp) {
|
||||
ORBIS_LOG_TRACE(__FUNCTION__, tp, tzp);
|
||||
struct ::timeval tv;
|
||||
struct ::timezone tz;
|
||||
if (::gettimeofday(&tv, &tz) != 0)
|
||||
if (::gettimeofday(&tv, nullptr) != 0)
|
||||
std::abort();
|
||||
if (tp) {
|
||||
orbis::timeval value;
|
||||
|
|
@ -126,9 +126,12 @@ orbis::SysResult orbis::sys_gettimeofday(Thread *thread, ptr<orbis::timeval> tp,
|
|||
return e;
|
||||
}
|
||||
if (tzp) {
|
||||
struct ::tm tp;
|
||||
if (localtime_r(&tv.tv_sec, &tp) != &tp)
|
||||
std::abort();
|
||||
orbis::timezone value;
|
||||
value.tz_dsttime = tz.tz_dsttime;
|
||||
value.tz_minuteswest = tz.tz_minuteswest;
|
||||
value.tz_dsttime = tp.tm_isdst;
|
||||
value.tz_minuteswest = -tp.tm_gmtoff / 60;
|
||||
if (auto e = uwrite(tzp, value); e != ErrorCode{})
|
||||
return e;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue