⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mm_malloc.h

📁 实现一个简单的单进程内核,。该内核启用二级虚拟页表映射
💻 H
字号:
/* A simple malloc implimentation from 15-213 * mm_malloc.h * * 213 mm_malloc macros and prototypes. * */#ifndef _MM_MALLOC_H#define _MM_MALLOC_H/* $begin mallocmacros *//* Basic constants and macros */#define WSIZE       4       /* word size (bytes) */#define DSIZE       8       /* doubleword size (bytes) */#define CHUNKSIZE  (1<<12)  /* initial heap size (bytes) */#define OVERHEAD    8       /* overhead of header and footer (bytes) */#define MAX(x, y) ((x) > (y)? (x) : (y))/* Pack a size and allocated bit into a word */#define PACK(size, alloc)  ((size) | (alloc))/* Read and write a word at address p */#define GET(p)       (*(int *)(p))#define PUT(p, val)  (*(int *)(p) = (val))/* Read the size and allocated fields from address p */#define GET_SIZE(p)  (GET(p) & ~0x7)#define GET_ALLOC(p) (GET(p) & 0x1)/* Given block ptr bp, compute address of its header and footer */#define HDRP(bp)       ((char *)(bp) - WSIZE)#define FTRP(bp)       ((char *)(bp) + GET_SIZE(HDRP(bp)) - DSIZE)/* Given block ptr bp, compute address of next and previous blocks */#define NEXT_BLKP(bp)  ((char *)(bp) + GET_SIZE(((char *)(bp) - WSIZE)))#define PREV_BLKP(bp)  ((char *)(bp) - GET_SIZE(((char *)(bp) - DSIZE)))/* $end mallocmacros */int mm_init(void);void *mm_malloc(int size);void mm_free(void *bp);void *mm_realloc(void *ptr, int size);#endif /* _MM_MALLOC_H */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -