1 #ifndef DEFINES_H 2 #define DEFINES_H 3 4 /* $OpenBSD: defines.h,v 1.14 2013/11/22 15:47:35 espie Exp $ */ 5 6 /* 7 * Copyright (c) 2001 Marc Espie. 8 * 9 * Redistribution and use in source and binary forms, with or without 10 * modification, are permitted provided that the following conditions 11 * are met: 12 * 1. Redistributions of source code must retain the above copyright 13 * notice, this list of conditions and the following disclaimer. 14 * 2. Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in the 16 * documentation and/or other materials provided with the distribution. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE OPENBSD PROJECT AND CONTRIBUTORS 19 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBSD 22 * PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 */ 30 31 #ifdef HAS_STDBOOL_H 32 # include <stdbool.h> 33 #else 34 typedef int bool; 35 # define false 0 36 # define true 1 37 #endif 38 39 /* define common types in an opaque way */ 40 struct GNode_; 41 typedef struct GNode_ GNode; 42 43 struct Location_; 44 typedef struct Location_ Location; 45 46 struct List_; 47 typedef struct List_ *Lst; 48 49 struct SymTable_; 50 typedef struct SymTable_ SymTable; 51 52 struct Buffer_; 53 typedef struct Buffer_ *Buffer; 54 55 struct Name; 56 57 struct ListNode_; 58 typedef struct ListNode_ *LstNode; 59 60 struct Job_; 61 typedef struct Job_ Job; 62 63 struct Suff_; 64 typedef struct Suff_ Suff; 65 66 /* some useful defines for gcc */ 67 68 #ifdef __GNUC__ 69 # define UNUSED __attribute__((__unused__)) 70 # define HAS_INLINES 71 # define INLINE __inline__ 72 #else 73 # define UNUSED 74 #endif 75 76 #ifdef HAS_INLINES 77 # ifndef INLINE 78 # define INLINE inline 79 # endif 80 #endif 81 82 /* 83 * debug control: 84 * There is one bit per module. It is up to the module what debug 85 * information to print. 86 */ 87 extern int debug; 88 #define DEBUG_ARCH 0x0001 89 #define DEBUG_COND 0x0002 90 #define DEBUG_DIR 0x0004 91 #define DEBUG_GRAPH1 0x0008 92 #define DEBUG_GRAPH2 0x0010 93 #define DEBUG_JOB 0x0020 94 #define DEBUG_MAKE 0x0040 95 #define DEBUG_SUFF 0x0080 96 #define DEBUG_TARG 0x0100 97 #define DEBUG_VAR 0x0200 98 #define DEBUG_FOR 0x0400 99 #define DEBUG_LOUD 0x0800 100 #define DEBUG_PARALLEL 0x1000 101 #define DEBUG_NAME_MATCHING 0x2000 102 #define DEBUG_QUICKDEATH 0x4000 103 #define DEBUG_EXPENSIVE 0x8000 104 #define DEBUG_KILL 0x10000 105 #define DEBUG_HELDJOBS 0x20000 106 #define DEBUG_DOUBLE 0x40000 107 #define DEBUG_TARGGROUP 0x80000 108 109 #define CONCAT(a,b) a##b 110 111 #define DEBUG(module) (debug & CONCAT(DEBUG_,module)) 112 113 #define ISLOWER(c) (islower((unsigned char)(c))) 114 #define ISUPPER(c) (isupper((unsigned char)(c))) 115 #define ISDIGIT(c) (isdigit((unsigned char)(c))) 116 #define ISXDIGIT(c) (isxdigit((unsigned char)(c))) 117 #define ISSPACE(c) (isspace((unsigned char)(c))) 118 #define TOUPPER(c) (toupper((unsigned char)(c))) 119 #define TOLOWER(c) (tolower((unsigned char)(c))) 120 121 #endif 122