Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
Loading...
Searching...
No Matches
align_ops.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2017 Roc Streaming authors
3 *
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 */
8
9//! @file roc_core/align_ops.h
10//! @brief Alignment operations.
11
12#ifndef ROC_CORE_ALIGN_OPS_H_
13#define ROC_CORE_ALIGN_OPS_H_
14
15#include "roc_core/stddefs.h"
16
17namespace roc {
18namespace core {
19
20//! Maximum aligned data unit.
21union AlignMax {
22 uint64_t u; //!< 8-byte integer.
23 double d; //!< 8-byte floating point.
24 void (*p)(); //!< 4-, 8- or 16-byte function pointer.
25};
26
27//! Alignment operations.
28class AlignOps {
29public:
30 //! Get maximum alignment for current platform.
31 static size_t max_alignment();
32
33 //! Return size aligned to maximum alignment.
34 static size_t align_max(size_t size);
35
36 //! Return size aligned to given alignment.
37 static size_t align_as(size_t size, size_t alignment);
38
39 //! Return padding needed for maximum alignment.
40 static size_t pad_max(size_t size);
41
42 //! Return padding needed for given alignment.
43 static size_t pad_as(size_t size, size_t alignment);
44};
45
46} // namespace core
47} // namespace roc
48
49#endif // ROC_CORE_ALIGN_OPS_H_
Alignment operations.
Definition align_ops.h:28
static size_t pad_max(size_t size)
Return padding needed for maximum alignment.
static size_t align_as(size_t size, size_t alignment)
Return size aligned to given alignment.
static size_t pad_as(size_t size, size_t alignment)
Return padding needed for given alignment.
static size_t align_max(size_t size)
Return size aligned to maximum alignment.
static size_t max_alignment()
Get maximum alignment for current platform.
Shared ownership intrusive pointer.
Definition shared_ptr.h:32
Root namespace.
Commonly used types and functions.
Maximum aligned data unit.
Definition align_ops.h:21
void(* p)()
4-, 8- or 16-byte function pointer.
Definition align_ops.h:24
double d
8-byte floating point.
Definition align_ops.h:23
uint64_t u
8-byte integer.
Definition align_ops.h:22