source: mainline/uspace/lib/c/include/macros.h@ cd1e3fc0

Last change on this file since cd1e3fc0 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: 1.0 KB
RevLine 
[fcd7053]1/*
[d7f7a4a]2 * SPDX-FileCopyrightText: 2009 Martin Decky
[fcd7053]3 *
[d7f7a4a]4 * SPDX-License-Identifier: BSD-3-Clause
[fcd7053]5 */
6
7/** @addtogroup libc
8 * @{
9 */
10/** @file
11 */
12
[4805495]13#ifndef _LIBC_MACROS_H_
14#define _LIBC_MACROS_H_
[fcd7053]15
[db24058]16#define min(a, b) ((a) < (b) ? (a) : (b))
17#define max(a, b) ((a) > (b) ? (a) : (b))
[7d7bc09]18#define mabs(a) ((a) >= 0 ? (a) : -(a))
[34b9299]19
[52f9c57]20#define ARRAY_SIZE(array) (sizeof(array) / sizeof(array[0]))
[db24058]21
[933cadf]22#define KiB2SIZE(kb) ((kb) << 10)
23#define MiB2SIZE(mb) ((mb) << 20)
[fcd7053]24
[831667a9]25#define STRING(arg) STRING_ARG(arg)
26#define STRING_ARG(arg) #arg
27
[36e9cd1]28#define LOWER32(arg) (((uint64_t) (arg)) & 0xffffffff)
29#define UPPER32(arg) (((((uint64_t) arg)) >> 32) & 0xffffffff)
[831667a9]30
31#define MERGE_LOUP32(lo, up) \
32 ((((uint64_t) (lo)) & 0xffffffff) \
33 | ((((uint64_t) (up)) & 0xffffffff) << 32))
[fcd7053]34
[a211838]35#define _paddname(line) PADD_ ## line ## __
[af60409]36#define _padd(width, line, n) uint ## width ## _t _paddname(line) [n]
[062d900]37
[af60409]38#define PADD32(n) _padd(32, __LINE__, n)
39#define PADD16(n) _padd(16, __LINE__, n)
40#define PADD8(n) _padd(8, __LINE__, n)
[fcd7053]41
[a211838]42#endif
[20b7c08]43
[fcd7053]44/** @}
45 */
Note: See TracBrowser for help on using the repository browser.