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>
9 * The authors hereby relinquish any claim to any copyright that they may have
10 * in this work, whether granted under contract or by operation of law or
11 * international treaty, and hereby commit to the public, at large, that they
12 * shall not, at any time in the future, seek to enforce any copyright in this
13 * work against any person or entity, or prevent any person or entity from
14 * copying, publishing, distributing or creating derivative works of this
19 #define UTIL_MACROS_H 1
21 #include <portable/macros.h>
24 * Used for iterating through arrays. ARRAY_SIZE returns the number of
25 * elements in the array (useful for a < upper bound in a for loop) and
26 * ARRAY_END returns a pointer to the element past the end (ISO C99 makes it
27 * legal to refer to such a pointer as long as it's never dereferenced).
29 #define ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0]))
30 #define ARRAY_END(array) (&(array)[ARRAY_SIZE(array)])
32 /* Used to name the elements of the array passed to pipe. */
36 /* Used for unused parameters to silence gcc warnings. */
37 #define UNUSED __attribute__((__unused__))
39 #endif /* UTIL_MACROS_H */