source: mainline/uspace/lib/c/include/align.h@ cb7be8f

Last change on this file since cb7be8f was d7f7a4a, checked in by Jiří Zárevúcky <zarevucky.jiri@…>, 3 years ago

Replace some license headers with SPDX identifier

Headers are replaced using tools/transorm-copyright.sh only
when it can be matched verbatim with the license header used
throughout most of the codebase.

  • Property mode set to 100644
File size: 861 bytes
RevLine 
[86d05fae]1/*
[d7f7a4a]2 * SPDX-FileCopyrightText: 2005 Jakub Jermar
[86d05fae]3 *
[d7f7a4a]4 * SPDX-License-Identifier: BSD-3-Clause
[86d05fae]5 */
6
[fadd381]7/** @addtogroup libc
[b2951e2]8 * @{
9 */
10/** @file
11 */
12
[4805495]13#ifndef _LIBC_ALIGN_H_
14#define _LIBC_ALIGN_H_
[86d05fae]15
[71f1cc1]16/** Align to the nearest lower address which is a power of two.
[86d05fae]17 *
[71f1cc1]18 * @param s Address or size to be aligned.
19 * @param a Size of alignment, must be power of 2.
[86d05fae]20 */
21#define ALIGN_DOWN(s, a) ((s) & ~((a) - 1))
22
[71f1cc1]23/** Align to the nearest higher address which is a power of two.
[86d05fae]24 *
[71f1cc1]25 * @param s Address or size to be aligned.
26 * @param a Size of alignment, must be power of 2.
[86d05fae]27 */
[bf9afa07]28#define ALIGN_UP(s, a) ((long)((s) + ((a) - 1)) & ~((long) (a) - 1))
[86d05fae]29
[71f1cc1]30/** Round up to the nearest higher boundary.
31 *
32 * @param n Number to be aligned.
33 * @param b Boundary, arbitrary unsigned number.
34 */
35#define ROUND_UP(n, b) (((n) / (b) + ((n) % (b) != 0)) * (b))
36
[86d05fae]37#endif
[b2951e2]38
[fadd381]39/** @}
[b2951e2]40 */
Note: See TracBrowser for help on using the repository browser.