1 /*
2  * Copyright (C) 2018 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #pragma once
17 
18 #include <stdint.h>
19 
20 namespace cuttlefish {
21 
22 // Keep the full disk size a multiple of 64k, for crosvm's virtio_blk driver
23 constexpr int DISK_SIZE_SHIFT = 16;
24 
25 // Keep all partitions 4k aligned, for host performance reasons
26 constexpr int PARTITION_SIZE_SHIFT = 12;
27 
28 // Returns the smallest multiple of 2^align_log greater than or equal to val.
AlignToPowerOf2(uint64_t val,uint8_t align_log)29 constexpr uint64_t AlignToPowerOf2(uint64_t val, uint8_t align_log) {
30   uint64_t align = 1ULL << align_log;
31   return ((val + (align - 1)) / align) * align;
32 }
33 
34 }  // namespace cuttlefish
35