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