From: notaz Date: Wed, 27 Jan 2010 15:16:25 +0000 (+0000) Subject: bugfixes related to mmap usage for ROM X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1ed480497a9adb926b9b70a2bbf542d43e8b3d54;p=libpicofe.git bugfixes related to mmap usage for ROM git-svn-id: file:///home/notaz/opt/svn/PicoDrive/platform@867 be3aeb3a-fb24-0410-a615-afba39da0efa --- diff --git a/linux/plat.c b/linux/plat.c index 492007c..f5742b9 100644 --- a/linux/plat.c +++ b/linux/plat.c @@ -1,3 +1,4 @@ +#define _GNU_SOURCE #include #include #include @@ -112,8 +113,9 @@ int plat_wait_event(int *fds_hnds, int count, int timeout_ms) void *plat_mmap(unsigned long addr, size_t size) { void *req, *ret; + req = (void *)addr; - ret = mmap(req, size, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_ANONYMOUS, -1, 0); + ret = mmap(req, size, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0); if (ret == MAP_FAILED) return NULL; if (ret != req) @@ -122,6 +124,19 @@ void *plat_mmap(unsigned long addr, size_t size) return ret; } +void *plat_mremap(void *ptr, size_t oldsize, size_t newsize) +{ + void *ret; + + ret = mremap(ptr, oldsize, newsize, MREMAP_MAYMOVE); + if (ret == MAP_FAILED) + return NULL; + if (ret != ptr) + printf("warning: mremap moved: %p -> %p\n", ptr, ret); + + return ret; +} + void plat_munmap(void *ptr, size_t size) { munmap(ptr, size);