2 * Copyright (c) 2001-2018 The strace developers.
5 * SPDX-License-Identifier: LGPL-2.1-or-later
8 #ifndef STRACE_MACROS_H
9 #define STRACE_MACROS_H
12 #include <sys/types.h>
14 #include "gcc_compat.h"
16 #define ARRAY_SIZE(a_) (sizeof(a_) / sizeof((a_)[0]) + MUST_BE_ARRAY(a_))
18 #define ARRSZ_PAIR(a_) a_, ARRAY_SIZE(a_)
20 #define STRINGIFY(...) #__VA_ARGS__
21 #define STRINGIFY_VAL(...) STRINGIFY(__VA_ARGS__)
24 # define MAX(a, b) (((a) > (b)) ? (a) : (b))
27 # define MIN(a, b) (((a) < (b)) ? (a) : (b))
29 #define CLAMP(val, min, max) MIN(MAX(min, val), max)
32 # define ROUNDUP(val_, div_) ((((val_) + (div_) - 1) / (div_)) * (div_))
36 # define offsetofend(type_, member_) \
37 (offsetof(type_, member_) + sizeof(((type_ *)0)->member_))
41 is_filled(const char *ptr, char fill, size_t size)
50 #define IS_ARRAY_ZERO(arr_) \
51 is_filled((const char *) (arr_), 0, sizeof(arr_) + MUST_BE_ARRAY(arr_))
53 #endif /* !STRACE_MACROS_H */