Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / src / common / align.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
3 /*
4  * Ceph - scalable distributed file system
5   *
6  * Copyright (C) 2015 XSky <haomai@xsky.com>
7  *
8  * Author: Haomai Wang <haomaiwang@gmail.com>
9  *
10  * This is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Lesser General Public
12  * License version 2.1, as published by the Free Software
13  * Foundation.  See file COPYING.
14  *
15  */
16
17 #ifndef CEPH_COMMON_ALIGN_H
18 #define CEPH_COMMON_ALIGN_H
19
20 template <typename T>
21 inline constexpr T align_up(T v, T align) {
22   return (v + align - 1) & ~(align - 1);
23 }
24
25 template <typename T>
26 inline constexpr T align_down(T v, T align) {
27   return v & ~(align - 1);
28 }
29
30 #endif /* CEPH_COMMON_ALIGN_H */