Skip to content

Commit

Permalink
[orbis-kernel] Fix sys_gettimeofday
Browse files Browse the repository at this point in the history
Disable sys_utc_to_localtime and sys_localtime_to_utc for now.
Libkernel will fallback to sys_gettimeofday.
  • Loading branch information
Nekotekina committed Jul 15, 2023
1 parent 1d4b96b commit 86d059d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion orbis-kernel/include/orbis/time.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ struct timeval {
int64_t tv_usec;
};
struct timezone {
sint tz_minuteswest;
sint tz_mineast;
sint tz_dsttime;
};
struct timesec {
Expand Down
8 changes: 8 additions & 0 deletions orbis-kernel/src/sys/sys_sce.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -857,6 +857,10 @@ orbis::SysResult orbis::sys_utc_to_localtime(Thread *thread, int64_t time,
int64_t *localtime,
orbis::timesec *_sec,
int *_dst_sec) {
// Disabled for now
thread->retval[0] = (int)ErrorCode::RANGE;
return {};

ORBIS_LOG_TRACE(__FUNCTION__, time, localtime, _sec, _dst_sec);
struct ::tm tp;
auto result = ::mktime(::localtime_r(&time, &tp));
Expand All @@ -870,6 +874,10 @@ orbis::SysResult orbis::sys_localtime_to_utc(Thread *thread, int64_t time,
uint unk, int64_t *ptime,
orbis::timesec *_sec,
int *_dst_sec) {
// Disabled for now
thread->retval[0] = (int)ErrorCode::RANGE;
return {};

ORBIS_LOG_TRACE(__FUNCTION__, time, unk, ptime, _sec, _dst_sec);
struct ::tm tp;
::time_t timez = 0;
Expand Down
4 changes: 2 additions & 2 deletions orbis-kernel/src/sys/sys_time.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ orbis::SysResult orbis::sys_gettimeofday(Thread *thread, ptr<orbis::timeval> tp,
if (localtime_r(&tv.tv_sec, &tp) != &tp)
std::abort();
orbis::timezone value;
value.tz_dsttime = tp.tm_isdst;
value.tz_minuteswest = -tp.tm_gmtoff / 60;
value.tz_dsttime = 0; // TODO
value.tz_mineast = tp.tm_gmtoff / 60;
if (auto e = uwrite(tzp, value); e != ErrorCode{})
return e;
}
Expand Down

0 comments on commit 86d059d

Please sign in to comment.