don't cast between long and pointers for win64
authornotaz <notasas@gmail.com>
Thu, 15 Sep 2022 21:03:40 +0000 (00:03 +0300)
committernotaz <notasas@gmail.com>
Thu, 15 Sep 2022 21:03:40 +0000 (00:03 +0300)
long is 32 bit there

frontend/main.c
libpcsxcore/psxmem.c
plugins/dfsound/freeze.c
plugins/gpu_neon/psx_gpu/psx_gpu.c

index 6be005a..d846d3c 100644 (file)
@@ -998,7 +998,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]);
        }
 
 #if !defined(_WIN32) && !defined(NO_DYLIB)
@@ -1013,7 +1013,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);
@@ -1036,7 +1036,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;
index 9bb3760..5d9b161 100644 (file)
@@ -71,13 +71,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 ret;
        }
 
-       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);
 
@@ -86,14 +86,14 @@ retry:
                        return MAP_FAILED;
                }
 
-               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;
                }
index a400cf7..51e9fd7 100644 (file)
@@ -187,8 +187,8 @@ static void load_channel(SPUCHAN *d, const SPUCHAN_orig *s, int ch)
  d->sinc = s->sinc;\r
  d->sinc_inv = 0;\r
  memcpy(spu.SB + ch * SB_SIZE, s->SB, sizeof(spu.SB[0]) * SB_SIZE);\r
- d->pCurr = (void *)((long)s->iCurr & 0x7fff0);\r
- d->pLoop = (void *)((long)s->iLoop & 0x7fff0);\r
+ d->pCurr = (void *)((uintptr_t)s->iCurr & 0x7fff0);\r
+ d->pLoop = (void *)((uintptr_t)s->iLoop & 0x7fff0);\r
  d->bReverb = s->bReverb;\r
  d->iLeftVolume = s->iLeftVolume;\r
  d->iRightVolume = s->iRightVolume;\r
@@ -258,7 +258,7 @@ long CALLBACK SPUfreeze(uint32_t ulFreezeMode, SPUFreeze_t * pF,
    pFO=(SPUOSSFreeze_t *)(pF+1);                       // store special stuff\r
 \r
    pFO->spuIrq = spu.regArea[(H_SPUirqAddr - 0x0c00) / 2];\r
-   if(spu.pSpuIrq) pFO->pSpuIrq  = (unsigned long)spu.pSpuIrq-(unsigned long)spu.spuMemC;\r
+   if(spu.pSpuIrq) pFO->pSpuIrq = spu.pSpuIrq - spu.spuMemC;\r
 \r
    pFO->spuAddr=spu.spuAddr;\r
    if(pFO->spuAddr==0) pFO->spuAddr=0xbaadf00d;\r
@@ -340,8 +340,8 @@ void LoadStateV5(SPUFreeze_t * pF)
   {\r
    load_channel(&spu.s_chan[i],&pFO->s_chan[i],i);\r
 \r
-   spu.s_chan[i].pCurr+=(unsigned long)spu.spuMemC;\r
-   spu.s_chan[i].pLoop+=(unsigned long)spu.spuMemC;\r
+   spu.s_chan[i].pCurr+=(uintptr_t)spu.spuMemC;\r
+   spu.s_chan[i].pLoop+=(uintptr_t)spu.spuMemC;\r
   }\r
 }\r
 \r
index 51ad152..85cf89f 100644 (file)
@@ -14,6 +14,7 @@
 
 #include <stdio.h>
 #include <stdlib.h>
+#include <stdint.h>
 #include <string.h>
 
 #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);