From b6b00dd55e035bfbe311a527b567962ffa77ee43 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 26 Jun 2024 18:18:37 +0200 Subject: Merging upstream version 1:4.15.2. Signed-off-by: Daniel Baumann --- lib/sizeof.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 lib/sizeof.h (limited to 'lib/sizeof.h') diff --git a/lib/sizeof.h b/lib/sizeof.h new file mode 100644 index 0000000..6847068 --- /dev/null +++ b/lib/sizeof.h @@ -0,0 +1,25 @@ +/* + * SPDX-FileCopyrightText: 2022-2023, Alejandro Colomar + * SPDX-License-Identifier: BSD-3-Clause + */ + + +#ifndef SHADOW_INCLUDE_LIBMISC_SIZEOF_H_ +#define SHADOW_INCLUDE_LIBMISC_SIZEOF_H_ + + +#include + +#include + +#include "must_be.h" + + +#define memberof(T, member) ((T){}.member) +#define WIDTHOF(x) (sizeof(x) * CHAR_BIT) +#define SIZEOF_ARRAY(a) (sizeof(a) + must_be_array(a)) +#define NITEMS(a) (SIZEOF_ARRAY((a)) / sizeof((a)[0])) +#define STRLEN(s) (NITEMS(s) - 1) + + +#endif // include guard -- cgit v1.2.3