2017-06-15 15:21:38 +10:00
|
|
|
/* devkitPPC is missing a few functions that are kinda needed for some cores.
|
|
|
|
* This should add them back in.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <wiiu/os.h>
|
|
|
|
#include <pwd.h>
|
|
|
|
#include <features/features_cpu.h>
|
|
|
|
|
2018-01-06 09:44:03 -03:00
|
|
|
/* This is usually in libogc; we can't use that on wiiu */
|
2017-06-15 15:21:38 +10:00
|
|
|
int usleep(useconds_t microseconds) {
|
|
|
|
OSSleepTicks(us_to_ticks(microseconds));
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-01-06 09:44:03 -03:00
|
|
|
/* Can't find this one anywhere for some reason :/ */
|
|
|
|
/* This could probably be done a lot better with some love */
|
2017-06-15 15:21:38 +10:00
|
|
|
int access(const char* path, int mode) {
|
2018-01-06 09:44:03 -03:00
|
|
|
return 0; /* TODO temp hack, real code below */
|
2017-06-15 15:21:38 +10:00
|
|
|
|
|
|
|
FILE* fd = fopen(path, "rb");
|
|
|
|
if (fd < 0) {
|
|
|
|
fclose(fd);
|
2018-01-06 09:44:03 -03:00
|
|
|
/* We're supposed to set errono here */
|
2017-06-15 15:21:38 +10:00
|
|
|
return -1;
|
|
|
|
} else {
|
|
|
|
fclose(fd);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-06 09:44:03 -03:00
|
|
|
/* Just hardcode the Linux User ID, we're not on linux anyway */
|
|
|
|
/* Feasible cool addition: nn::act for this? */
|
2017-06-15 15:21:38 +10:00
|
|
|
uid_t getuid() {
|
|
|
|
return 1000;
|
|
|
|
}
|
|
|
|
|
2018-01-06 09:44:03 -03:00
|
|
|
/* Fake user info */
|
|
|
|
/* Not thread safe, but avoids returning local variable, so... */
|
2017-06-15 15:21:38 +10:00
|
|
|
struct passwd out;
|
|
|
|
struct passwd* getpwuid(uid_t uid) {
|
|
|
|
out.pw_name = "retroarch";
|
|
|
|
out.pw_passwd = "Wait, what?";
|
|
|
|
out.pw_uid = uid;
|
|
|
|
out.pw_gid = 1000;
|
|
|
|
out.pw_gecos = "retroarch";
|
|
|
|
out.pw_dir = "sd:/";
|
|
|
|
out.pw_shell = "/vol/system_slc/fw.img";
|
|
|
|
|
|
|
|
return &out;
|
|
|
|
}
|
|
|
|
|
2018-01-06 09:44:03 -03:00
|
|
|
/* Try to vaugely spoof the POISX clock. Epoch is off by about 30 */
|
|
|
|
/* years, so this could be better... */
|
|
|
|
/* Only has second accuracy since I'm lazy. */
|
2017-06-15 15:21:38 +10:00
|
|
|
int clock_gettime(clockid_t clk_id, struct timespec* tp) {
|
|
|
|
int64_t time_usec = cpu_features_get_time_usec();
|
|
|
|
tp->tv_sec = time_usec / 1000000;
|
|
|
|
return 0;
|
|
|
|
}
|