From: notaz Date: Thu, 15 Sep 2022 21:03:40 +0000 (+0300) Subject: don't cast between long and pointers for win64 X-Git-Tag: r24~305 X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?p=pcsx_rearmed.git;a=commitdiff_plain;h=77e1e47949d469acab865d38fe7493a4a295139e don't cast between long and pointers for win64 long is 32 bit there --- diff --git a/frontend/main.c b/frontend/main.c index 671068d3..60ec51cd 100644 --- a/frontend/main.c +++ b/frontend/main.c @@ -989,7 +989,7 @@ void *SysLoadLibrary(const char *lib) { tmp++; for (i = 0; i < ARRAY_SIZE(builtin_plugins); i++) if (strcmp(tmp, builtin_plugins[i]) == 0) - return (void *)(long)(PLUGIN_DL_BASE + builtin_plugin_ids[i]); + return (void *)(uintptr_t)(PLUGIN_DL_BASE + builtin_plugin_ids[i]); } #ifndef _WIN32 @@ -1004,7 +1004,7 @@ void *SysLoadLibrary(const char *lib) { } void *SysLoadSym(void *lib, const char *sym) { - unsigned int plugid = (unsigned int)(long)lib; + unsigned int plugid = (unsigned int)(uintptr_t)lib; if (PLUGIN_DL_BASE <= plugid && plugid < PLUGIN_DL_BASE + ARRAY_SIZE(builtin_plugins)) return plugin_link(plugid - PLUGIN_DL_BASE, sym); @@ -1025,7 +1025,7 @@ const char *SysLibError() { } void SysCloseLibrary(void *lib) { - unsigned int plugid = (unsigned int)(long)lib; + unsigned int plugid = (unsigned int)(uintptr_t)lib; if (PLUGIN_DL_BASE <= plugid && plugid < PLUGIN_DL_BASE + ARRAY_SIZE(builtin_plugins)) return; diff --git a/libpcsxcore/psxmem.c b/libpcsxcore/psxmem.c index 46cee0ca..2a963334 100644 --- a/libpcsxcore/psxmem.c +++ b/libpcsxcore/psxmem.c @@ -59,13 +59,13 @@ retry: /* if (is_fixed) flags |= MAP_FIXED; */ - req = (void *)addr; + req = (void *)(uintptr_t)addr; ret = mmap(req, size, PROT_READ | PROT_WRITE, flags, -1, 0); if (ret == MAP_FAILED) return NULL; } - if (addr != 0 && ret != (void *)addr) { + if (addr != 0 && ret != (void *)(uintptr_t)addr) { SysMessage("psxMap: warning: wanted to map @%08x, got %p\n", addr, ret); @@ -74,14 +74,14 @@ retry: return NULL; } - if (((addr ^ (unsigned long)ret) & ~0xff000000l) && try_ < 2) + if (((addr ^ (unsigned long)(uintptr_t)ret) & ~0xff000000l) && try_ < 2) { psxUnmap(ret, size, tag); // try to use similarly aligned memory instead // (recompiler needs this) mask = try_ ? 0xffff : 0xffffff; - addr = ((unsigned long)ret + mask) & ~mask; + addr = ((uintptr_t)ret + mask) & ~mask; try_++; goto retry; } diff --git a/plugins/dfsound/freeze.c b/plugins/dfsound/freeze.c index a400cf7c..51e9fd77 100644 --- a/plugins/dfsound/freeze.c +++ b/plugins/dfsound/freeze.c @@ -187,8 +187,8 @@ static void load_channel(SPUCHAN *d, const SPUCHAN_orig *s, int ch) d->sinc = s->sinc; d->sinc_inv = 0; memcpy(spu.SB + ch * SB_SIZE, s->SB, sizeof(spu.SB[0]) * SB_SIZE); - d->pCurr = (void *)((long)s->iCurr & 0x7fff0); - d->pLoop = (void *)((long)s->iLoop & 0x7fff0); + d->pCurr = (void *)((uintptr_t)s->iCurr & 0x7fff0); + d->pLoop = (void *)((uintptr_t)s->iLoop & 0x7fff0); d->bReverb = s->bReverb; d->iLeftVolume = s->iLeftVolume; d->iRightVolume = s->iRightVolume; @@ -258,7 +258,7 @@ long CALLBACK SPUfreeze(uint32_t ulFreezeMode, SPUFreeze_t * pF, pFO=(SPUOSSFreeze_t *)(pF+1); // store special stuff pFO->spuIrq = spu.regArea[(H_SPUirqAddr - 0x0c00) / 2]; - if(spu.pSpuIrq) pFO->pSpuIrq = (unsigned long)spu.pSpuIrq-(unsigned long)spu.spuMemC; + if(spu.pSpuIrq) pFO->pSpuIrq = spu.pSpuIrq - spu.spuMemC; pFO->spuAddr=spu.spuAddr; if(pFO->spuAddr==0) pFO->spuAddr=0xbaadf00d; @@ -340,8 +340,8 @@ void LoadStateV5(SPUFreeze_t * pF) { load_channel(&spu.s_chan[i],&pFO->s_chan[i],i); - spu.s_chan[i].pCurr+=(unsigned long)spu.spuMemC; - spu.s_chan[i].pLoop+=(unsigned long)spu.spuMemC; + spu.s_chan[i].pCurr+=(uintptr_t)spu.spuMemC; + spu.s_chan[i].pLoop+=(uintptr_t)spu.spuMemC; } } diff --git a/plugins/gpu_neon/psx_gpu/psx_gpu.c b/plugins/gpu_neon/psx_gpu/psx_gpu.c index 51ad152d..85cf89fa 100644 --- a/plugins/gpu_neon/psx_gpu/psx_gpu.c +++ b/plugins/gpu_neon/psx_gpu/psx_gpu.c @@ -14,6 +14,7 @@ #include #include +#include #include #include "common.h" @@ -4016,7 +4017,7 @@ void setup_sprite_untextured_simple(psx_gpu_struct *psx_gpu, s32 x, s32 y, num_width = width; vram_ptr = (void *)vram_ptr16; - if((long)vram_ptr16 & 2) + if((uintptr_t)vram_ptr16 & 2) { *vram_ptr16 = color_32bpp; vram_ptr = (void *)(vram_ptr16 + 1);