mirror of https://github.com/mgba-emu/mgba.git
PSP2: Use sceKernelLibcLocaltime_r instead of faking it
This commit is contained in:
parent
bb2b82d15e
commit
b4c86ea161
|
@ -11,7 +11,7 @@ source_group("PS Vita-specific code" FILES ${OS_SRC})
|
|||
list(APPEND VFS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/sce-vfs.c)
|
||||
set(VFS_SRC ${VFS_SRC} PARENT_SCOPE)
|
||||
|
||||
set(OS_LIB -lvita2d -lSceCtrl_stub -lSceRtc_stub -lSceGxm_stub -lSceDisplay_stub -lSceAudio_stub -lSceMotion_stub -lScePower_stub -lSceTouch_stub -lSceCommonDialog_stub -lpng -lz -l${M_LIBRARY})
|
||||
set(OS_LIB -lvita2d -lSceCtrl_stub -lSceGxm_stub -lSceDisplay_stub -lSceAudio_stub -lSceMotion_stub -lScePower_stub -lSceTouch_stub -lSceCommonDialog_stub -lpng -lz -l${M_LIBRARY})
|
||||
set(OBJCOPY_CMD ${OBJCOPY} -I binary -O elf32-littlearm -B arm)
|
||||
|
||||
list(APPEND GUI_SRC ${CMAKE_CURRENT_SOURCE_DIR}/gui-font.c)
|
||||
|
|
|
@ -73,29 +73,12 @@ float strtof_u(const char* restrict str, char** restrict end) {
|
|||
}
|
||||
|
||||
#ifndef HAVE_LOCALTIME_R
|
||||
#ifdef PSP2
|
||||
#include <psp2/rtc.h>
|
||||
#endif
|
||||
|
||||
struct tm* localtime_r(const time_t* t, struct tm* date) {
|
||||
#ifdef _WIN32
|
||||
localtime_s(date, t);
|
||||
return date;
|
||||
#elif defined(PSP2)
|
||||
SceRtcTime sceRtc;
|
||||
uint64_t tick, localtick;
|
||||
sceRtcSetTime_t(&sceRtc, *t);
|
||||
sceRtcGetTick(&sceRtc, &tick);
|
||||
sceRtcConvertUtcToLocalTime(&tick, &localtick);
|
||||
sceRtcSetTick(&sceRtc, &localtick);
|
||||
date->tm_year = sceRtc.year;
|
||||
date->tm_mon = sceRtc.month;
|
||||
date->tm_mday = sceRtc.day;
|
||||
date->tm_hour = sceRtc.hour;
|
||||
date->tm_min = sceRtc.minutes;
|
||||
date->tm_sec = sceRtc.seconds;
|
||||
date->tm_wday = sceRtcGetDayOfWeek(sceRtc.year, sceRtc.month, sceRtc.day);
|
||||
return date;
|
||||
return sceKernelLibcLocaltime_r(t, date);
|
||||
#else
|
||||
#warning localtime_r not emulated on this platform
|
||||
return 0;
|
||||
|
|
Loading…
Reference in New Issue