libjit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Libjit] jit_vmem_commit


From: Aleksey Demakov
Subject: Re: [Libjit] jit_vmem_commit
Date: Wed, 15 Aug 2018 02:08:38 +0300

Hi Eli,

You are right, I'll fix this.

Regards,
Aleksey
On Tue, Aug 14, 2018 at 8:47 PM Eli Zaretskii <address@hidden> wrote:
>
> 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.
>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]