Capitalize mode enum value

master
Shuxin Yang 2014-12-09 10:22:37 -08:00
parent 839698668b
commit c3e010b11f
4 changed files with 13 additions and 13 deletions

View File

@ -32,7 +32,7 @@ lm_alloc_chunk (ljmm_mode_t mode) {
/* The chunk must be page-aligned, and are multiple pages in size. */
cur_brk = (page_sz - 1 + cur_brk) & ~(page_sz - 1);
uintptr_t upbound = (mode == lm_user_mode) ? SIZE_2GB : SIZE_1GB;
uintptr_t upbound = (mode == LM_USER_MODE) ? SIZE_2GB : SIZE_1GB;
if (cur_brk >= upbound)
return NULL;

10
lj_mm.h
View File

@ -10,20 +10,20 @@ extern "C" {
typedef enum {
/* lm_mmap() is done exclusively by the user mode mmap. */
lm_user_mode = 0,
LM_USER_MODE = 0,
/* lm_mmap() is done exclusively by the mmap(2). */
lm_sys_mode = 1,
LM_SYS_MODE = 1,
/* lm_mmap() attempts user-mode mmap first, then mmap(2). */
lm_prefer_user = 2,
LM_PREFER_USER = 2,
/* lm_mmap attemps mmap(2) first. If it was not succesful,
* attempt user-mode mmap
*/
lm_prefer_sys = 3,
LM_PREFER_SYS = 3,
lm_default = lm_user_mode
LM_DEFAULT = LM_USER_MODE
} ljmm_mode_t;
/* Additional options, primiarilly for debugging purpose */

View File

@ -14,11 +14,11 @@
/* Forward Decl */
static int lm_unmap_helper(void* addr, size_t um_size);
static ljmm_mode_t ljmm_mode = lm_default;
static ljmm_mode_t ljmm_mode = LM_DEFAULT;
void
lm_init_mm_opt(ljmm_opt_t* opt) {
opt->mode = lm_default;
opt->mode = LM_DEFAULT;
opt->dbg_alloc_page_num = -1;
opt->enable_block_cache = 0;
opt->blk_cache_in_page = 0;
@ -390,7 +390,7 @@ lm_munmap(void* addr, size_t length) {
* unmap it with munmap(2).
*/
if (!lm_in_chunk_range(addr)) {
if (ljmm_mode != lm_user_mode)
if (ljmm_mode != LM_USER_MODE)
return munmap(addr, length);
errno = EINVAL;
@ -433,9 +433,9 @@ lm_mmap(void *addr, size_t length, int prot, int flags,
}
void *p = NULL;
if (ljmm_mode == lm_prefer_sys || ljmm_mode == lm_sys_mode) {
if (ljmm_mode == LM_PREFER_SYS || ljmm_mode == LM_SYS_MODE) {
p = mmap(addr, length, prot, flags, fd, offset);
if (p != MAP_FAILED || ljmm_mode == lm_sys_mode)
if (p != MAP_FAILED || ljmm_mode == LM_SYS_MODE)
return p;
}
@ -497,7 +497,7 @@ lm_init2(ljmm_opt_t* opt) {
/* Look like we run out of (0, 1 GB] space, we have to resort
* to mmap(2).
*/
ljmm_mode = lm_sys_mode;
ljmm_mode = LM_SYS_MODE;
}
return 0;

View File

@ -95,7 +95,7 @@ UNIT_TEST::UNIT_TEST(int test_id, int page_num)
lm_init_mm_opt(&mm_opt);
mm_opt.dbg_alloc_page_num = _page_num = page_num;
mm_opt.mode = lm_user_mode;
mm_opt.mode = LM_USER_MODE;
_init_succ = lm_init2(&mm_opt);
_test_succ = _init_succ ? true : false;