]> eyrie.org Git - kerberos/krb5-strength.git/blob - util/macros.h
New upstream version 3.1
[kerberos/krb5-strength.git] / util / macros.h
1 /*
2  * Some standard helpful macros.
3  *
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/>.
6  *
7  * Written by Russ Allbery <eagle@eyrie.org>
8  *
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
15  * work.
16  */
17
18 #ifndef UTIL_MACROS_H
19 #define UTIL_MACROS_H 1
20
21 #include <portable/macros.h>
22
23 /*
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).
28  */
29 #define ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0]))
30 #define ARRAY_END(array)  (&(array)[ARRAY_SIZE(array)])
31
32 /* Used to name the elements of the array passed to pipe. */
33 #define PIPE_READ  0
34 #define PIPE_WRITE 1
35
36 /* Used for unused parameters to silence gcc warnings. */
37 #define UNUSED __attribute__((__unused__))
38
39 #endif /* UTIL_MACROS_H */