Root - Categorised TODO List
[tpg/acess2.git] / AcessNative / ld-acess_src / memory.c
index 627f902..2e9612c 100644 (file)
@@ -27,10 +27,14 @@ int AllocateMemory(uintptr_t VirtAddr, size_t ByteCount)
                return -1;
        }
        #else
+//     printf("AllocateMemory: mmap(%p, 0x%lx, ...)\n", (void*)base, ByteCount);
        tmp = mmap((void*)base, size, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0);
        if( tmp == MAP_FAILED ) {
+               printf("ERROR: Unable to allocate memory\n");
+               perror("AllocateMemory");
                return -1;
        }
+//     printf("AllocateMemory: RETURN 0\n");
        #endif
        return 0;
 }
@@ -42,14 +46,14 @@ uintptr_t FindFreeRange(size_t ByteCount, int MaxBits)
        #else
        uintptr_t       base, ofs, size;
        uintptr_t       end = -1;
-       const int       PAGE_SIZE = 0x1000;
+       static const int        PAGE_SIZE = 0x1000;
        
        size = (ByteCount + PAGE_SIZE - 1) / PAGE_SIZE;
        size *= PAGE_SIZE;
 
        end <<= (sizeof(intptr_t)*8-MaxBits);
        end >>= (sizeof(intptr_t)*8-MaxBits);
-       printf("end = %p\n", (void*)end);
+//     printf("end = %p\n", (void*)end);
        
 //     for( base = 0; base < end - size; base -= PAGE_SIZE )
        for( base = end - size + 1; base > 0; base -= PAGE_SIZE )

UCC git Repository :: git.ucc.asn.au