memory.h: overall cleanup

Replace repeating (VALUE_2MB - 1) with MASK_2MB, etc.
No functional changes, just cleanup.

Change-Id: I6a9ebfb0ebebd3c29f6174c57ea01738b26feddc
Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1040
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
Darek Stojaczyk 2020-02-27 14:12:31 +01:00 committed by Tomasz Zawadzki
parent f1d292a367
commit 8aa58de3f2

View File

@ -41,17 +41,17 @@ extern "C" {
#endif #endif
#define SHIFT_2MB 21 /* (1 << 21) == 2MB */ #define SHIFT_2MB 21 /* (1 << 21) == 2MB */
#define MASK_2MB ((1ULL << SHIFT_2MB) - 1) #define VALUE_2MB (1ULL << SHIFT_2MB)
#define VALUE_2MB (1 << SHIFT_2MB) #define MASK_2MB (VALUE_2MB - 1)
#define SHIFT_4KB 12 /* (1 << 12) == 4KB */ #define SHIFT_4KB 12 /* (1 << 12) == 4KB */
#define MASK_4KB ((1ULL << SHIFT_4KB) - 1) #define VALUE_4KB (1ULL << SHIFT_4KB)
#define VALUE_4KB (1 << SHIFT_4KB) #define MASK_4KB (VALUE_4KB - 1)
#define _2MB_OFFSET(ptr) (((uintptr_t)(ptr)) & (VALUE_2MB - 1)) #define _2MB_OFFSET(ptr) (((uintptr_t)(ptr)) & MASK_2MB)
#define _2MB_PAGE(ptr) ((ptr) & ~(0x200000 - 1)) #define _2MB_PAGE(ptr) FLOOR_2MB((uintptr_t)(ptr))
#define FLOOR_2MB(x) (((uintptr_t)x) / VALUE_2MB) << SHIFT_2MB #define FLOOR_2MB(x) (((uintptr_t)(x)) & ~MASK_2MB)
#define CEIL_2MB(x) ((((uintptr_t)x) + VALUE_2MB - 1) / VALUE_2MB) << SHIFT_2MB #define CEIL_2MB(x) FLOOR_2MB(((uintptr_t)(x)) + VALUE_2MB - 1)
#ifdef __cplusplus #ifdef __cplusplus
} }