X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=linux%2Fplat.c;h=9109a3242c5e251fc63083820e3290d557a654af;hb=de24250ab5038797e8f5ff8754d34a3219943134;hp=2842691e5e22d2e65be373eb10a26b27942ea8ea;hpb=448ec62f85a90e8a27368ddc05057a5a714944b8;p=libpicofe.git diff --git a/linux/plat.c b/linux/plat.c index 2842691..9109a32 100644 --- a/linux/plat.c +++ b/linux/plat.c @@ -41,7 +41,15 @@ int plat_is_dir(const char *path) 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); @@ -65,7 +73,7 @@ static int plat_get_data_dir(char *dst, int len) 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; @@ -78,7 +86,7 @@ int plat_get_skin_dir(char *dst, int len) #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; @@ -90,7 +98,7 @@ int plat_get_root_dir(char *dst, int len) return ret; } #endif - return plat_get_data_dir(dst, len); + return plat_get_exe_dir(dst, len); } #ifdef __GP2X__ @@ -184,6 +192,10 @@ void *plat_mmap(unsigned long addr, size_t size, int need_exec, int is_fixed) */ if (size >= HUGETLB_THRESHOLD) flags |= MAP_HUGETLB; +#ifdef MAP_JIT + if (need_exec) + flags |= MAP_JIT; +#endif ret = mmap(req, size, prot, flags, -1, 0); if (ret == MAP_FAILED && (flags & MAP_HUGETLB)) { @@ -215,8 +227,11 @@ void *plat_mremap(void *ptr, size_t oldsize, size_t newsize) { void *ret; +#ifdef MREMAP_MAYMOVE ret = mremap(ptr, oldsize, newsize, MREMAP_MAYMOVE); - if (ret == MAP_FAILED) { + if (ret == MAP_FAILED) +#endif + { fprintf(stderr, "mremap %p %zd %zd: ", ptr, oldsize, newsize); perror(NULL);