[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Libjit] jit_vmem_commit
From: |
Eli Zaretskii |
Subject: |
[Libjit] jit_vmem_commit |
Date: |
Tue, 14 Aug 2018 18:24:34 +0300 |
Here's the definition of that function in current HEAD:
int
jit_vmem_commit(void *addr, jit_uint size, jit_prot_t prot)
{
#if defined(JIT_VMEM_WIN32)
DWORD nprot;
nprot = convert_prot(prot);
return VirtualAlloc(addr, size, MEM_COMMIT, nprot);
#elif defined(JIT_VMEM_MMAP)
int nprot;
nprot = convert_prot(prot);
addr = mmap(0, size, nprot, MAP_FIXED|MAP_PRIVATE|MAP_ANONYMOUS, -1,
0);
if(addr == MAP_FAILED)
{
return (void *) 0;
}
return addr;
#else
return 0;
#endif
}
I think the return type should be either changed to intptr_t, or the
value should be a boolean, e.g.:
if(addr == MAP_FAILED)
{
return 0;
}
return 1;
Trying to implicitly cast an address to an int will emit warnings, and
on 64-bit hosts will not work properly.
Thanks.
P.S. Please CC me on responses, as I'm not subscribed to this list.
- [Libjit] jit_vmem_commit,
Eli Zaretskii <=