1 /*
2  * Portability wrapper around <stdbool.h>.
3  *
4  * Provides the bool and _Bool types and the true and false constants,
5  * following the C99 specification, on hosts that don't have stdbool.h.  This
6  * logic is based heavily on the example in the Autoconf manual.
7  *
8  * The canonical version of this file is maintained in the rra-c-util package,
9  * which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
10  *
11  * Written by Russ Allbery <eagle@eyrie.org>
12  * Copyright 2008, 2011
13  *     The Board of Trustees of the Leland Stanford Junior University
14  *
15  * Copying and distribution of this file, with or without modification, are
16  * permitted in any medium without royalty provided the copyright notice and
17  * this notice are preserved.  This file is offered as-is, without any
18  * warranty.
19  *
20  * SPDX-License-Identifier: FSFAP
21  */
22 
23 #ifndef PORTABLE_STDBOOL_H
24 #define PORTABLE_STDBOOL_H 1
25 
26 /*
27  * Allow inclusion of config.h to be skipped, since sometimes we have to use a
28  * stripped-down version of config.h with a different name.
29  */
30 #ifndef CONFIG_H_INCLUDED
31 #    include <config.h>
32 #endif
33 
34 #if HAVE_STDBOOL_H
35 #    include <stdbool.h>
36 #else
37 #    if HAVE__BOOL
38 #        define bool _Bool
39 #    else
40 #        ifdef __cplusplus
41 typedef bool _Bool;
42 #        elif _WIN32
43 #            include <windef.h>
44 #            define bool BOOL
45 #        else
46 typedef unsigned char _Bool;
47 #            define bool _Bool
48 #        endif
49 #    endif
50 #    define false 0
51 #    define true 1
52 #    define __bool_true_false_are_defined 1
53 #endif
54 
55 /*
56  * If we define bool and don't tell Perl, it will try to define its own and
57  * fail.  Only of interest for programs that also include Perl headers.
58  */
59 #ifndef HAS_BOOL
60 #    define HAS_BOOL 1
61 #endif
62 
63 #endif /* !PORTABLE_STDBOOL_H */
64