#ifndef __CUSTOM_MEM__H_ #define __CUSTOM_MEM__H_ #include #include typedef struct box64context_s box64context_t; void* customMalloc(size_t size); void* customMalloc32(size_t size); void* customCalloc(size_t n, size_t size); void* customCalloc32(size_t n, size_t size); void* customRealloc(void* p, size_t size); void* customRealloc32(void* p, size_t size); void* customMemAligned(size_t align, size_t size); void* customMemAligned32(size_t align, size_t size); void customFree(void* p); void customFree32(void* p); size_t customGetUsableSize(void* p); #define kcalloc customCalloc #define kmalloc customMalloc #define krealloc customRealloc #define kfree customFree #define ALIGN(p) (((p)+box64_pagesize-1)&~(box64_pagesize-1)) #ifndef MAP_32BIT #define MAP_32BIT 0x40 #endif #ifdef DYNAREC typedef struct dynablock_s dynablock_t; typedef struct mmaplist_s mmaplist_t; typedef struct DynaCacheBlock_s DynaCacheBlock_t; // custom protection flag to mark Page that are Write protected for Dynarec purpose uintptr_t AllocDynarecMap(uintptr_t x64_addr, size_t size, int is_new); void FreeDynarecMap(uintptr_t addr); mmaplist_t* NewMmaplist(); void DelMmaplist(mmaplist_t* list); int MmaplistHasNew(mmaplist_t* list, int clear); int MmaplistNBlocks(mmaplist_t* list); void MmaplistFillBlocks(mmaplist_t* list, DynaCacheBlock_t* blocks); void MmaplistAddNBlocks(mmaplist_t* list, int nblocks); int MmaplistAddBlock(mmaplist_t* list, int fd, off_t offset, void* orig, size_t size, intptr_t delta_map, uintptr_t mapping_start); void addDBFromAddressRange(uintptr_t addr, size_t size); // Will return 1 if at least 1 db in the address range int cleanDBFromAddressRange(uintptr_t addr, size_t size, int destroy); dynablock_t* getDB(uintptr_t idx); int getNeedTest(uintptr_t idx); int addJumpTableIfDefault64(void* addr, void* jmp); // return 1 if write was succesfull int setJumpTableIfRef64(void* addr, void* jmp, void* ref); // return 1 if write was succesfull void setJumpTableDefault64(void* addr); void setJumpTableDefaultRef64(void* addr, void* jmp); int isJumpTableDefault64(void* addr); uintptr_t getJumpTable64(void); uintptr_t getJumpTable48(void); uintptr_t getJumpTable32(void); uintptr_t getJumpTableAddress64(uintptr_t addr); uintptr_t getJumpAddress64(uintptr_t addr); #ifdef SAVE_MEM #define JMPTABL_SHIFTMAX JMPTABL_SHIFT4 #define JMPTABL_SHIFT4 16 #define JMPTABL_SHIFT3 16 #define JMPTABL_SHIFT2 12 #define JMPTABL_SHIFT1 12 #define JMPTABL_SHIFT0 10 #define JMPTABL_START4 (JMPTABL_START3+JMPTABL_SHIFT3) #define JMPTABL_START3 (JMPTABL_START2+JMPTABL_SHIFT2) #define JMPTABL_START2 (JMPTABL_START1+JMPTABL_SHIFT1) #define JMPTABL_START1 (JMPTABL_START0+JMPTABL_SHIFT0) #define JMPTABL_START0 0 #define JMPTABLE_MASK4 ((1<