1 #ifndef DEFINES_H 2 #define DEFINES_H 3 4 /* $OpenBSD: defines.h,v 1.16 2023/09/05 14:05:41 jsg 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 #else 65 # define UNUSED 66 #endif 67 68 /* 69 * debug control: 70 * There is one bit per module. It is up to the module what debug 71 * information to print. 72 */ 73 extern int debug; 74 #define DEBUG_ARCH 0x0001 75 #define DEBUG_COND 0x0002 76 #define DEBUG_DIR 0x0004 77 #define DEBUG_GRAPH1 0x0008 78 #define DEBUG_GRAPH2 0x0010 79 #define DEBUG_JOB 0x0020 80 #define DEBUG_MAKE 0x0040 81 #define DEBUG_SUFF 0x0080 82 #define DEBUG_TARG 0x0100 83 #define DEBUG_VAR 0x0200 84 #define DEBUG_FOR 0x0400 85 #define DEBUG_LOUD 0x0800 86 #define DEBUG_PARALLEL 0x1000 87 #define DEBUG_NAME_MATCHING 0x2000 88 #define DEBUG_QUICKDEATH 0x4000 89 #define DEBUG_EXPENSIVE 0x8000 90 #define DEBUG_KILL 0x10000 91 #define DEBUG_HELDJOBS 0x20000 92 #define DEBUG_DOUBLE 0x40000 93 #define DEBUG_TARGGROUP 0x80000 94 95 #define CONCAT(a,b) a##b 96 97 #define DEBUG(module) (debug & CONCAT(DEBUG_,module)) 98 99 #define ISLOWER(c) (islower((unsigned char)(c))) 100 #define ISUPPER(c) (isupper((unsigned char)(c))) 101 #define ISDIGIT(c) (isdigit((unsigned char)(c))) 102 #define ISXDIGIT(c) (isxdigit((unsigned char)(c))) 103 #define ISSPACE(c) (isspace((unsigned char)(c))) 104 #define TOUPPER(c) (toupper((unsigned char)(c))) 105 #define TOLOWER(c) (tolower((unsigned char)(c))) 106 107 #endif 108