- tmp = VirtualAlloc(base, size, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
+ tmp = VirtualAlloc((void*)base, size, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
tmp = mmap((void*)base, size, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0);
if( tmp == MAP_FAILED ) {
tmp = mmap((void*)base, size, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0);
if( tmp == MAP_FAILED ) {
size = (ByteCount + PAGE_SIZE - 1) / PAGE_SIZE;
size *= PAGE_SIZE;
end <<= (sizeof(intptr_t)*8-MaxBits);
end >>= (sizeof(intptr_t)*8-MaxBits);
size = (ByteCount + PAGE_SIZE - 1) / PAGE_SIZE;
size *= PAGE_SIZE;
end <<= (sizeof(intptr_t)*8-MaxBits);
end >>= (sizeof(intptr_t)*8-MaxBits);
// for( base = 0; base < end - size; base -= PAGE_SIZE )
for( base = end - size + 1; base > 0; base -= PAGE_SIZE )
{
for( ofs = 0; ofs < size; ofs += PAGE_SIZE ) {
// for( base = 0; base < end - size; base -= PAGE_SIZE )
for( base = end - size + 1; base > 0; base -= PAGE_SIZE )
{
for( ofs = 0; ofs < size; ofs += PAGE_SIZE ) {
if( msync( (void*)(base+ofs), 1, 0) == 0 )
break;
if( errno != ENOMEM )
perror("FindFreeRange, msync");
if( msync( (void*)(base+ofs), 1, 0) == 0 )
break;
if( errno != ENOMEM )
perror("FindFreeRange, msync");