#ifndef __CUSTOM_MEM__H_ #define __CUSTOM_MEM__H_ #include #include typedef struct box64context_s box64context_t; void* customMalloc(size_t size); void* customCalloc(size_t n, size_t size); void* customRealloc(void* p, size_t size); void customFree(void* p); #define kcalloc customCalloc #define kmalloc customMalloc #define krealloc customRealloc #define kfree customFree #define ALIGN(p) (((p)+box64_pagesize-1)&~(box64_pagesize-1)) #ifdef DYNAREC typedef struct dynablock_s dynablock_t; // custom protection flag to mark Page that are Write protected for Dynarec purpose uintptr_t AllocDynarecMap(size_t size); void FreeDynarecMap(uintptr_t addr); void addDBFromAddressRange(uintptr_t addr, size_t size); void cleanDBFromAddressRange(uintptr_t addr, size_t size, int destroy); // Will return 1 if at least 1 db in the address range int isDBFromAddressRange(uintptr_t addr, size_t size); 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 getJumpTable32(void); uintptr_t getJumpTableAddress64(uintptr_t addr); uintptr_t getJumpAddress64(uintptr_t addr); #ifdef SAVE_MEM #define JMPTABL_SHIFT4 16 #define JMPTABL_SHIFT3 14 #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<