2 * Some standard helpful macros.
4 * The canonical version of this file is maintained in the rra-c-util package,
5 * which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
7 * Written by Russ Allbery <eagle@eyrie.org>
8 * Copyright 2014 Russ Allbery <eagle@eyrie.org>
10 * The Board of Trustees of the Leland Stanford Junior University
12 * Copying and distribution of this file, with or without modification, are
13 * permitted in any medium without royalty provided the copyright notice and
14 * this notice are preserved. This file is offered as-is, without any
17 * SPDX-License-Identifier: FSFAP
21 #define UTIL_MACROS_H 1
23 #include <portable/macros.h>
26 * Used for iterating through arrays. ARRAY_SIZE returns the number of
27 * elements in the array (useful for a < upper bound in a for loop) and
28 * ARRAY_END returns a pointer to the element past the end (ISO C99 makes it
29 * legal to refer to such a pointer as long as it's never dereferenced).
31 #define ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0]))
32 #define ARRAY_END(array) (&(array)[ARRAY_SIZE(array)])
34 /* Used to name the elements of the array passed to pipe. */
38 /* Used for unused parameters to silence gcc warnings. */
39 #define UNUSED __attribute__((__unused__))
41 #endif /* UTIL_MACROS_H */