forked from vmware/splinterdb
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move abstract base implementation into allocator.c (vmware#519)
Co-authored-by: Jon Howell <[email protected]>
- Loading branch information
Showing
3 changed files
with
30 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Copyright 2018-2021 VMware, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
/* | ||
* allocator.c -- | ||
* | ||
* This file implements the abstract base behavior shared by allocators. | ||
*/ | ||
|
||
#include "allocator.h" | ||
#include "poison.h" | ||
|
||
void | ||
allocator_config_init(allocator_config *allocator_cfg, | ||
io_config *io_cfg, | ||
uint64 capacity) | ||
{ | ||
ZERO_CONTENTS(allocator_cfg); | ||
|
||
allocator_cfg->io_cfg = io_cfg; | ||
allocator_cfg->capacity = capacity; | ||
|
||
allocator_cfg->page_capacity = capacity / io_cfg->page_size; | ||
allocator_cfg->extent_capacity = capacity / io_cfg->extent_size; | ||
uint64 log_extent_size = 63 - __builtin_clzll(io_cfg->extent_size); | ||
allocator_cfg->extent_mask = ~((1ULL << log_extent_size) - 1); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters