return 0;
}
-static int plat_get_data_dir(char *dst, int len)
+int plat_get_data_dir(char *dst, int len)
+{
+ if (len > 1)
+ strcpy(dst, "/");
+ else *dst = 0;
+ return strlen(dst);
+}
+
+static int plat_get_exe_dir(char *dst, int len)
{
#ifdef PICO_DATA_DIR
memcpy(dst, PICO_DATA_DIR, sizeof PICO_DATA_DIR);
int plat_get_skin_dir(char *dst, int len)
{
- int ret = plat_get_data_dir(dst, len);
+ int ret = plat_get_exe_dir(dst, len);
if (ret < 0)
return ret;
#endif
int plat_get_root_dir(char *dst, int len)
{
-#if !defined(__GP2X__) && !defined(PANDORA)
+#if !defined(NO_HOME_DIR) && !defined(__GP2X__) && !defined(PANDORA)
const char *home = getenv("HOME");
int ret;
return ret;
}
#endif
- return plat_get_data_dir(dst, len);
+ return plat_get_exe_dir(dst, len);
}
#ifdef __GP2X__
void *ret;
ret = mremap(ptr, oldsize, newsize, MREMAP_MAYMOVE);
- if (ret == MAP_FAILED)
- return NULL;
+ if (ret == MAP_FAILED) {
+ fprintf(stderr, "mremap %p %zd %zd: ",
+ ptr, oldsize, newsize);
+ perror(NULL);
+ // might be because huge pages can't be remapped,
+ // just make a new mapping
+ ret = plat_mmap(0, newsize, 0, 0);
+ if (ret == MAP_FAILED)
+ return NULL;
+ memcpy(ret, ptr, oldsize);
+ munmap(ptr, oldsize);
+ }
if (ret != ptr)
printf("warning: mremap moved: %p -> %p\n", ptr, ret);