Add missing_libc_functions.c (for DOSBox)

This commit is contained in:
Ash 2017-06-15 15:21:38 +10:00
parent 7f5986e1d5
commit 2492f3d6b3
2 changed files with 62 additions and 0 deletions

View File

@ -11,6 +11,7 @@ PC_DEVELOPMENT_TCP_PORT ?=
OBJ :=
OBJ += wiiu/system/memory.o
OBJ += wiiu/system/exception_handler.o
OBJ += wiiu/system/missing_libc_functions.o
OBJ += wiiu/fs/sd_fat_devoptab.o
OBJ += wiiu/fs/fs_utils.o
OBJ += wiiu/controller_patcher/ControllerPatcher.o

View File

@ -0,0 +1,61 @@
/* 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>
//This is usually in libogc; we can't use that on wiiu
int usleep(useconds_t microseconds) {
OSSleepTicks(us_to_ticks(microseconds));
return 0;
}
//Can't find this one anywhere for some reason :/
//This could probably be done a lot better with some love
int access(const char* path, int mode) {
return 0; //TODO temp hack, real code below
FILE* fd = fopen(path, "rb");
if (fd < 0) {
fclose(fd);
//We're supposed to set errono here
return -1;
} else {
fclose(fd);
return 0;
}
}
//Just hardcode the Linux User ID, we're not on linux anyway
//Feasible cool addition: nn::act for this?
uid_t getuid() {
return 1000;
}
//Fake user info
//Not thread safe, but avoids returning local variable, so...
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;
}
//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.
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;
}