]> eyrie.org Git - kerberos/krb5-strength.git/blob - util/macros.h
Make xmalloc diagnostic suppression conditional
[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  * Copyright 2014 Russ Allbery <eagle@eyrie.org>
9  * Copyright 2008-2011
10  *     The Board of Trustees of the Leland Stanford Junior University
11  *
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
15  * warranty.
16  *
17  * SPDX-License-Identifier: FSFAP
18  */
19
20 #ifndef UTIL_MACROS_H
21 #define UTIL_MACROS_H 1
22
23 #include <portable/macros.h>
24
25 /*
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).
30  */
31 #define ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0]))
32 #define ARRAY_END(array)  (&(array)[ARRAY_SIZE(array)])
33
34 /* Used to name the elements of the array passed to pipe. */
35 #define PIPE_READ         0
36 #define PIPE_WRITE        1
37
38 /* Used for unused parameters to silence gcc warnings. */
39 #define UNUSED            __attribute__((__unused__))
40
41 #endif /* UTIL_MACROS_H */