-
Notifications
You must be signed in to change notification settings - Fork 289
Expand file tree
/
Copy pathsizeof.h
More file actions
35 lines (22 loc) · 804 Bytes
/
Copy pathsizeof.h
File metadata and controls
35 lines (22 loc) · 804 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// SPDX-FileCopyrightText: 2022-2025, Alejandro Colomar <alx@kernel.org>
// SPDX-License-Identifier: BSD-3-Clause
#ifndef SHADOW_INCLUDE_LIBMISC_SIZEOF_H_
#define SHADOW_INCLUDE_LIBMISC_SIZEOF_H_
#include "config.h"
#include <limits.h>
#if __has_include(<stdcountof.h>)
# include <stdcountof.h>
#endif
#include <sys/types.h>
#include "cast.h"
#define typeas(T) typeof((T){0})
#define ssizeof(x) rvalue((ssize_t){sizeof(x)})
#define memberof(T, member) ((T){}.member)
#define WIDTHOF(x) (sizeof(x) * CHAR_BIT)
#if !defined(countof)
# define countof(a) (sizeof(a) / sizeof((a)[0]))
#endif
// sizeof_a - sizeof array
#define sizeof_a(a) (countof(a) * sizeof((a)[0]))
#define STRLEN(s) (countof("" s "") - 1)
#endif // include guard