1 #ifndef DEFINES_H 2 #define DEFINES_H 3 4 /* $OpenBSD: defines.h,v 1.15 2015/10/14 13:50:22 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 # include <stdbool.h> 32 33 /* define common types in an opaque way */ 34 struct GNode_; 35 typedef struct GNode_ GNode; 36 37 struct Location_; 38 typedef struct Location_ Location; 39 40 struct List_; 41 typedef struct List_ *Lst; 42 43 struct SymTable_; 44 typedef struct SymTable_ SymTable; 45 46 struct Buffer_; 47 typedef struct Buffer_ *Buffer; 48 49 struct Name; 50 51 struct ListNode_; 52 typedef struct ListNode_ *LstNode; 53 54 struct Job_; 55 typedef struct Job_ Job; 56 57 struct Suff_; 58 typedef struct Suff_ Suff; 59 60 /* some useful defines for gcc */ 61 62 #ifdef __GNUC__ 63 # define UNUSED __attribute__((__unused__)) 64 # define HAS_INLINES 65 # define INLINE __inline__ 66 #else 67 # define UNUSED 68 #endif 69 70 #ifdef HAS_INLINES 71 # ifndef INLINE 72 # define INLINE inline 73 # endif 74 #endif 75 76 /* 77 * debug control: 78 * There is one bit per module. It is up to the module what debug 79 * information to print. 80 */ 81 extern int debug; 82 #define DEBUG_ARCH 0x0001 83 #define DEBUG_COND 0x0002 84 #define DEBUG_DIR 0x0004 85 #define DEBUG_GRAPH1 0x0008 86 #define DEBUG_GRAPH2 0x0010 87 #define DEBUG_JOB 0x0020 88 #define DEBUG_MAKE 0x0040 89 #define DEBUG_SUFF 0x0080 90 #define DEBUG_TARG 0x0100 91 #define DEBUG_VAR 0x0200 92 #define DEBUG_FOR 0x0400 93 #define DEBUG_LOUD 0x0800 94 #define DEBUG_PARALLEL 0x1000 95 #define DEBUG_NAME_MATCHING 0x2000 96 #define DEBUG_QUICKDEATH 0x4000 97 #define DEBUG_EXPENSIVE 0x8000 98 #define DEBUG_KILL 0x10000 99 #define DEBUG_HELDJOBS 0x20000 100 #define DEBUG_DOUBLE 0x40000 101 #define DEBUG_TARGGROUP 0x80000 102 103 #define CONCAT(a,b) a##b 104 105 #define DEBUG(module) (debug & CONCAT(DEBUG_,module)) 106 107 #define ISLOWER(c) (islower((unsigned char)(c))) 108 #define ISUPPER(c) (isupper((unsigned char)(c))) 109 #define ISDIGIT(c) (isdigit((unsigned char)(c))) 110 #define ISXDIGIT(c) (isxdigit((unsigned char)(c))) 111 #define ISSPACE(c) (isspace((unsigned char)(c))) 112 #define TOUPPER(c) (toupper((unsigned char)(c))) 113 #define TOLOWER(c) (tolower((unsigned char)(c))) 114 115 #endif 116