From 85f2398236b54db46340dad14330102f281ca4f3 Mon Sep 17 00:00:00 2001 From: notaz Date: Wed, 25 Mar 2015 00:39:24 +0200 Subject: [PATCH] psxmem: fix error handling also bump libpicofe for mmap fix --- frontend/libpicofe | 2 +- libpcsxcore/psxmem.c | 28 ++++++++++++++-------------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/frontend/libpicofe b/frontend/libpicofe index 9fec8a91..26ea1817 160000 --- a/frontend/libpicofe +++ b/frontend/libpicofe @@ -1 +1 @@ -Subproject commit 9fec8a91c9b19856ac0b51de53b847b38ed8dc61 +Subproject commit 26ea18173c1228dd5ce39e2a88ffe1ae10fcb365 diff --git a/libpcsxcore/psxmem.c b/libpcsxcore/psxmem.c index 86da68ce..6277220c 100644 --- a/libpcsxcore/psxmem.c +++ b/libpcsxcore/psxmem.c @@ -49,20 +49,21 @@ void *psxMap(unsigned long addr, size_t size, int is_fixed, retry: if (psxMapHook != NULL) { - ret = psxMapHook(addr, size, is_fixed, tag); - goto out; + ret = psxMapHook(addr, size, 0, tag); + if (ret == NULL) + return NULL; + } + else { + /* avoid MAP_FIXED, it overrides existing mappings.. */ + /* if (is_fixed) + flags |= MAP_FIXED; */ + + req = (void *)addr; + ret = mmap(req, size, PROT_READ | PROT_WRITE, flags, -1, 0); + if (ret == MAP_FAILED) + return NULL; } - /* avoid MAP_FIXED, it overrides existing mappings.. */ - /* if (is_fixed) - flags |= MAP_FIXED; */ - - req = (void *)addr; - ret = mmap(req, size, PROT_READ | PROT_WRITE, flags, -1, 0); - if (ret == MAP_FAILED) - return NULL; - -out: if (addr != 0 && ret != (void *)addr) { SysMessage("psxMap: warning: wanted to map @%08x, got %p\n", addr, ret); @@ -72,8 +73,7 @@ out: return NULL; } - if (ret != NULL && ((addr ^ (long)ret) & 0x00ffffff) - && !tried_to_align) + if (((addr ^ (long)ret) & 0x00ffffff) && !tried_to_align) { psxUnmap(ret, size, tag); -- 2.39.2