make.h revision 1.155 1 /* $NetBSD: make.h,v 1.155 2020/10/05 19:27:47 rillig Exp $ */
2
3 /*
4 * Copyright (c) 1988, 1989, 1990, 1993
5 * The Regents of the University of California. All rights reserved.
6 *
7 * This code is derived from software contributed to Berkeley by
8 * Adam de Boor.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. Neither the name of the University nor the names of its contributors
19 * may be used to endorse or promote products derived from this software
20 * without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
33 *
34 * from: @(#)make.h 8.3 (Berkeley) 6/13/95
35 */
36
37 /*
38 * Copyright (c) 1989 by Berkeley Softworks
39 * All rights reserved.
40 *
41 * This code is derived from software contributed to Berkeley by
42 * Adam de Boor.
43 *
44 * Redistribution and use in source and binary forms, with or without
45 * modification, are permitted provided that the following conditions
46 * are met:
47 * 1. Redistributions of source code must retain the above copyright
48 * notice, this list of conditions and the following disclaimer.
49 * 2. Redistributions in binary form must reproduce the above copyright
50 * notice, this list of conditions and the following disclaimer in the
51 * documentation and/or other materials provided with the distribution.
52 * 3. All advertising materials mentioning features or use of this software
53 * must display the following acknowledgement:
54 * This product includes software developed by the University of
55 * California, Berkeley and its contributors.
56 * 4. Neither the name of the University nor the names of its contributors
57 * may be used to endorse or promote products derived from this software
58 * without specific prior written permission.
59 *
60 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
61 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
62 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
63 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
64 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
65 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
66 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
67 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
68 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
69 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
70 * SUCH DAMAGE.
71 *
72 * from: @(#)make.h 8.3 (Berkeley) 6/13/95
73 */
74
75 /*-
76 * make.h --
77 * The global definitions for pmake
78 */
79
80 #ifndef MAKE_MAKE_H
81 #define MAKE_MAKE_H
82
83 #include <sys/types.h>
84 #include <sys/param.h>
85 #include <sys/stat.h>
86
87 #include <assert.h>
88 #include <ctype.h>
89 #include <fcntl.h>
90 #include <stdarg.h>
91 #include <stdio.h>
92 #include <stdlib.h>
93 #include <string.h>
94 #include <unistd.h>
95
96 #ifdef BSD4_4
97 # include <sys/cdefs.h>
98 #endif
99
100 #ifndef FD_CLOEXEC
101 #define FD_CLOEXEC 1
102 #endif
103
104 #if defined(__GNUC__)
105 #define MAKE_GNUC_PREREQ(x, y) \
106 ((__GNUC__ == (x) && __GNUC_MINOR__ >= (y)) || \
107 (__GNUC__ > (x)))
108 #else /* defined(__GNUC__) */
109 #define MAKE_GNUC_PREREQ(x, y) 0
110 #endif /* defined(__GNUC__) */
111
112 #if MAKE_GNUC_PREREQ(2, 7)
113 #define MAKE_ATTR_UNUSED __attribute__((__unused__))
114 #else
115 #define MAKE_ATTR_UNUSED /* delete */
116 #endif
117
118 #if MAKE_GNUC_PREREQ(2, 5)
119 #define MAKE_ATTR_DEAD __attribute__((__noreturn__))
120 #elif defined(__GNUC__)
121 #define MAKE_ATTR_DEAD __volatile
122 #else
123 #define MAKE_ATTR_DEAD /* delete */
124 #endif
125
126 #if MAKE_GNUC_PREREQ(2, 7)
127 #define MAKE_ATTR_PRINTFLIKE(fmtarg, firstvararg) \
128 __attribute__((__format__ (__printf__, fmtarg, firstvararg)))
129 #else
130 #define MAKE_ATTR_PRINTFLIKE(fmtarg, firstvararg) /* delete */
131 #endif
132
133 /*
134 * A boolean type is defined as an integer, not an enum, for historic reasons.
135 * The only allowed values are the constants TRUE and FALSE (1 and 0).
136 */
137
138 #ifdef USE_DOUBLE_BOOLEAN
139 /* During development, to find type mismatches in function declarations. */
140 typedef double Boolean;
141 #elif defined(USE_UCHAR_BOOLEAN)
142 /* During development, to find code that depends on the exact value of TRUE or
143 * that stores other values in Boolean variables. */
144 typedef unsigned char Boolean;
145 #define TRUE ((unsigned char)0xFF)
146 #define FALSE ((unsigned char)0x00)
147 #elif defined(USE_ENUM_BOOLEAN)
148 typedef enum { FALSE, TRUE } Boolean;
149 #else
150 typedef int Boolean;
151 #endif
152 #ifndef TRUE
153 #define TRUE 1
154 #endif
155 #ifndef FALSE
156 #define FALSE 0
157 #endif
158
159 #include "lst.h"
160 #include "enum.h"
161 #include "hash.h"
162 #include "config.h"
163 #include "buf.h"
164 #include "make_malloc.h"
165
166 typedef enum {
167 UNMADE, /* Not examined yet */
168 DEFERRED, /* Examined once (building child) */
169 REQUESTED, /* on toBeMade list */
170 BEINGMADE, /* Target is already being made.
171 * Indicates a cycle in the graph. */
172 MADE, /* Was out-of-date and has been made */
173 UPTODATE, /* Was already up-to-date */
174 ERROR, /* An error occurred while it was being
175 * made (used only in compat mode) */
176 ABORTED /* The target was aborted due to an error
177 * making an inferior (compat). */
178 } GNodeMade;
179
180 /* The OP_ constants are used when parsing a dependency line as a way of
181 * communicating to other parts of the program the way in which a target
182 * should be made.
183 *
184 * These constants are bitwise-OR'ed together and placed in the 'type' field
185 * of each node. Any node that has a 'type' field which satisfies the OP_NOP
186 * function was never never on the left-hand side of an operator, though it
187 * may have been on the right-hand side... */
188 typedef enum {
189 /* Execution of commands depends on children (:) */
190 OP_DEPENDS = 1 << 0,
191 /* Always execute commands (!) */
192 OP_FORCE = 1 << 1,
193 /* Execution of commands depends on children per line (::) */
194 OP_DOUBLEDEP = 1 << 2,
195
196 OP_OPMASK = OP_DEPENDS|OP_FORCE|OP_DOUBLEDEP,
197
198 /* Don't care if the target doesn't exist and can't be created */
199 OP_OPTIONAL = 1 << 3,
200 /* Use associated commands for parents */
201 OP_USE = 1 << 4,
202 /* Target is never out of date, but always execute commands anyway.
203 * Its time doesn't matter, so it has none...sort of */
204 OP_EXEC = 1 << 5,
205 /* Ignore errors when creating the node */
206 OP_IGNORE = 1 << 6,
207 /* Don't remove the target when interrupted */
208 OP_PRECIOUS = 1 << 7,
209 /* Don't echo commands when executed */
210 OP_SILENT = 1 << 8,
211 /* Target is a recursive make so its commands should always be executed
212 * when it is out of date, regardless of the state of the -n or -t flags */
213 OP_MAKE = 1 << 9,
214 /* Target is out-of-date only if any of its children was out-of-date */
215 OP_JOIN = 1 << 10,
216 /* Assume the children of the node have been already made */
217 OP_MADE = 1 << 11,
218 /* Special .BEGIN, .END, .INTERRUPT */
219 OP_SPECIAL = 1 << 12,
220 /* Like .USE, only prepend commands */
221 OP_USEBEFORE = 1 << 13,
222 /* The node is invisible to its parents. I.e. it doesn't show up in the
223 * parents' local variables. */
224 OP_INVISIBLE = 1 << 14,
225 /* The node is exempt from normal 'main target' processing in parse.c */
226 OP_NOTMAIN = 1 << 15,
227 /* Not a file target; run always */
228 OP_PHONY = 1 << 16,
229 /* Don't search for file in the path */
230 OP_NOPATH = 1 << 17,
231 /* .WAIT phony node */
232 OP_WAIT = 1 << 18,
233 /* .NOMETA do not create a .meta file */
234 OP_NOMETA = 1 << 19,
235 /* .META we _do_ want a .meta file */
236 OP_META = 1 << 20,
237 /* Do not compare commands in .meta file */
238 OP_NOMETA_CMP = 1 << 21,
239 /* Possibly a submake node */
240 OP_SUBMAKE = 1 << 22,
241
242 /* Attributes applied by PMake */
243
244 /* The node is a transformation rule */
245 OP_TRANSFORM = 1 << 31,
246 /* Target is a member of an archive */
247 OP_MEMBER = 1 << 30,
248 /* Target is a library */
249 OP_LIB = 1 << 29,
250 /* Target is an archive construct */
251 OP_ARCHV = 1 << 28,
252 /* Target has all the commands it should. Used when parsing to catch
253 * multiple commands for a target. */
254 OP_HAS_COMMANDS = 1 << 27,
255 /* The special command "..." has been seen. All further commands from
256 * this node will be saved on the .END node instead, to be executed at
257 * the very end. */
258 OP_SAVE_CMDS = 1 << 26,
259 /* Already processed by Suff_FindDeps */
260 OP_DEPS_FOUND = 1 << 25,
261 /* Node found while expanding .ALLSRC */
262 OP_MARK = 1 << 24,
263
264 OP_NOTARGET = OP_NOTMAIN | OP_USE | OP_EXEC | OP_TRANSFORM
265 } GNodeType;
266
267 typedef enum {
268 REMAKE = 0x0001, /* this target needs to be (re)made */
269 CHILDMADE = 0x0002, /* children of this target were made */
270 FORCE = 0x0004, /* children don't exist, and we pretend made */
271 DONE_WAIT = 0x0008, /* Set by Make_ProcessWait() */
272 DONE_ORDER = 0x0010, /* Build requested by .ORDER processing */
273 FROM_DEPEND = 0x0020, /* Node created from .depend */
274 DONE_ALLSRC = 0x0040, /* We do it once only */
275 CYCLE = 0x1000, /* Used by MakePrintStatus */
276 DONECYCLE = 0x2000, /* Used by MakePrintStatus */
277 INTERNAL = 0x4000 /* Internal use only */
278 } GNodeFlags;
279
280 typedef struct List StringList;
281 typedef struct ListNode StringListNode;
282
283 typedef struct List GNodeList;
284 typedef struct ListNode GNodeListNode;
285
286 typedef struct List /* of CachedDir */ SearchPath;
287
288 /* A graph node represents a target that can possibly be made, including its
289 * relation to other targets and a lot of other details. */
290 typedef struct GNode {
291 /* The target's name, such as "clean" or "make.c" */
292 char *name;
293 /* The unexpanded name of a .USE node */
294 char *uname;
295 /* The full pathname of the file belonging to the target.
296 * XXX: What about .PHONY targets? These don't have an associated path. */
297 char *path;
298
299 /* The type of operator used to define the sources (see the OP flags below).
300 * XXX: This looks like a wild mixture of type and flags. */
301 GNodeType type;
302 /* whether it is involved in this invocation of make */
303 GNodeFlags flags;
304
305 /* The state of processing on this node */
306 GNodeMade made;
307 int unmade; /* The number of unmade children */
308
309 time_t mtime; /* Its modification time */
310 struct GNode *cmgn; /* The youngest child */
311
312 /* The GNodes for which this node is an implied source. May be empty.
313 * For example, when there is an inference rule for .c.o, the node for
314 * file.c has the node for file.o in this list. */
315 GNodeList *implicitParents;
316
317 /* Other nodes of the same name for the :: operator. */
318 GNodeList *cohorts;
319
320 /* The nodes that depend on this one, or in other words, the nodes for
321 * which this is a source. */
322 GNodeList *parents;
323 /* The nodes on which this one depends. */
324 GNodeList *children;
325
326 /* .ORDER nodes we need made. The nodes that must be made (if they're
327 * made) before this node can be made, but that do not enter into the
328 * datedness of this node. */
329 GNodeList *order_pred;
330 /* .ORDER nodes who need us. The nodes that must be made (if they're made
331 * at all) after this node is made, but that do not depend on this node,
332 * in the normal sense. */
333 GNodeList *order_succ;
334
335 /* #n for this cohort */
336 char cohort_num[8];
337 /* The number of unmade instances on the cohorts list */
338 int unmade_cohorts;
339 /* Pointer to the first instance of a '::' node; only set when on a
340 * cohorts list */
341 struct GNode *centurion;
342
343 /* Last time (sequence number) we tried to make this node */
344 unsigned int checked;
345
346 /* The "local" variables that are specific to this target and this target
347 * only, such as $@, $<, $?. */
348 Hash_Table context;
349
350 /* The commands to be given to a shell to create this target. */
351 StringList *commands;
352
353 /* Suffix for the node (determined by Suff_FindDeps and opaque to everyone
354 * but the Suff module) */
355 struct Suff *suffix;
356
357 /* filename where the GNode got defined */
358 const char *fname;
359 /* line number where the GNode got defined */
360 int lineno;
361 } GNode;
362
363 /*
364 * Error levels for parsing. PARSE_FATAL means the process cannot continue
365 * once the makefile has been parsed. PARSE_WARNING means it can. Passed
366 * as the first argument to Parse_Error.
367 */
368 #define PARSE_INFO 3
369 #define PARSE_WARNING 2
370 #define PARSE_FATAL 1
371
372 /*
373 * Values returned by Cond_EvalLine and Cond_EvalCondition.
374 */
375 typedef enum {
376 COND_PARSE, /* Parse the next lines */
377 COND_SKIP, /* Skip the next lines */
378 COND_INVALID /* Not a conditional statement */
379 } CondEvalResult;
380
381 /*
382 * Definitions for the "local" variables. Used only for clarity.
383 */
384 #define TARGET "@" /* Target of dependency */
385 #define OODATE "?" /* All out-of-date sources */
386 #define ALLSRC ">" /* All sources */
387 #define IMPSRC "<" /* Source implied by transformation */
388 #define PREFIX "*" /* Common prefix */
389 #define ARCHIVE "!" /* Archive in "archive(member)" syntax */
390 #define MEMBER "%" /* Member in "archive(member)" syntax */
391
392 #define FTARGET "@F" /* file part of TARGET */
393 #define DTARGET "@D" /* directory part of TARGET */
394 #define FIMPSRC "<F" /* file part of IMPSRC */
395 #define DIMPSRC "<D" /* directory part of IMPSRC */
396 #define FPREFIX "*F" /* file part of PREFIX */
397 #define DPREFIX "*D" /* directory part of PREFIX */
398
399 /*
400 * Global Variables
401 */
402 extern StringList *create; /* The list of target names specified on the
403 * command line. used to resolve #if
404 * make(...) statements */
405 extern SearchPath *dirSearchPath;
406 /* The list of directories to search when
407 * looking for targets */
408
409 extern Boolean compatMake; /* True if we are make compatible */
410 extern Boolean ignoreErrors; /* True if should ignore all errors */
411 extern Boolean beSilent; /* True if should print no commands */
412 extern Boolean noExecute; /* True if should execute nothing */
413 extern Boolean noRecursiveExecute;
414 /* True if should execute nothing */
415 extern Boolean allPrecious; /* True if every target is precious */
416 extern Boolean deleteOnError; /* True if failed targets should be deleted */
417 extern Boolean keepgoing; /* True if should continue on unaffected
418 * portions of the graph when have an error
419 * in one portion */
420 extern Boolean touchFlag; /* TRUE if targets should just be 'touched'
421 * if out of date. Set by the -t flag */
422 extern Boolean queryFlag; /* TRUE if we aren't supposed to really make
423 * anything, just see if the targets are out-
424 * of-date */
425 extern Boolean doing_depend; /* TRUE if processing .depend */
426
427 extern Boolean checkEnvFirst; /* TRUE if environment should be searched for
428 * variables before the global context */
429
430 extern Boolean parseWarnFatal; /* TRUE if makefile parsing warnings are
431 * treated as errors */
432
433 extern Boolean varNoExportEnv; /* TRUE if we should not export variables
434 * set on the command line to the env. */
435
436 extern GNode *DEFAULT; /* .DEFAULT rule */
437
438 extern GNode *VAR_INTERNAL; /* Variables defined internally by make
439 * which should not override those set by
440 * makefiles.
441 */
442 extern GNode *VAR_GLOBAL; /* Variables defined in a global context, e.g
443 * in the Makefile itself */
444 extern GNode *VAR_CMD; /* Variables defined on the command line */
445 extern char var_Error[]; /* Value returned by Var_Parse when an error
446 * is encountered. It actually points to
447 * an empty string, so naive callers needn't
448 * worry about it. */
449
450 extern time_t now; /* The time at the start of this whole
451 * process */
452
453 extern Boolean oldVars; /* Do old-style variable substitution */
454
455 extern SearchPath *sysIncPath; /* The system include path. */
456 extern SearchPath *defIncPath; /* The default include path. */
457
458 extern char curdir[]; /* Startup directory */
459 extern char *progname; /* The program name */
460 extern char *makeDependfile; /* .depend */
461 extern char **savedEnv; /* if we replaced environ this will be non-NULL */
462
463 extern int makelevel;
464
465 /*
466 * We cannot vfork() in a child of vfork().
467 * Most systems do not enforce this but some do.
468 */
469 #define vFork() ((getpid() == myPid) ? vfork() : fork())
470 extern pid_t myPid;
471
472 #define MAKEFLAGS ".MAKEFLAGS"
473 #define MAKEOVERRIDES ".MAKEOVERRIDES"
474 #define MAKE_JOB_PREFIX ".MAKE.JOB.PREFIX" /* prefix for job target output */
475 #define MAKE_EXPORTED ".MAKE.EXPORTED" /* variables we export */
476 #define MAKE_MAKEFILES ".MAKE.MAKEFILES" /* all the makefiles we read */
477 #define MAKE_LEVEL ".MAKE.LEVEL" /* recursion level */
478 #define MAKEFILE_PREFERENCE ".MAKE.MAKEFILE_PREFERENCE"
479 #define MAKE_DEPENDFILE ".MAKE.DEPENDFILE" /* .depend */
480 #define MAKE_MODE ".MAKE.MODE"
481 #ifndef MAKE_LEVEL_ENV
482 # define MAKE_LEVEL_ENV "MAKELEVEL"
483 #endif
484
485 /*
486 * debug control:
487 * There is one bit per module. It is up to the module what debug
488 * information to print.
489 */
490 extern FILE *debug_file; /* Output is written here - default stderr */
491 extern int debug;
492 #define DEBUG_ARCH 0x00001
493 #define DEBUG_COND 0x00002
494 #define DEBUG_DIR 0x00004
495 #define DEBUG_GRAPH1 0x00008
496 #define DEBUG_GRAPH2 0x00010
497 #define DEBUG_JOB 0x00020
498 #define DEBUG_MAKE 0x00040
499 #define DEBUG_SUFF 0x00080
500 #define DEBUG_TARG 0x00100
501 #define DEBUG_VAR 0x00200
502 #define DEBUG_FOR 0x00400
503 #define DEBUG_SHELL 0x00800
504 #define DEBUG_ERROR 0x01000
505 #define DEBUG_LOUD 0x02000
506 #define DEBUG_META 0x04000
507 #define DEBUG_HASH 0x08000
508
509 #define DEBUG_GRAPH3 0x10000
510 #define DEBUG_SCRIPT 0x20000
511 #define DEBUG_PARSE 0x40000
512 #define DEBUG_CWD 0x80000
513
514 #define DEBUG_LINT 0x100000
515
516 #define CONCAT(a,b) a##b
517
518 #define DEBUG(module) (debug & CONCAT(DEBUG_,module))
519
520 void debug_printf(const char *, ...) MAKE_ATTR_PRINTFLIKE(1, 2);
521
522 #define DEBUG0(module, text) \
523 if (!DEBUG(module)) (void)0; \
524 else debug_printf("%s", text)
525
526 #define DEBUG1(module, fmt, arg1) \
527 if (!DEBUG(module)) (void)0; \
528 else debug_printf(fmt, arg1)
529
530 #define DEBUG2(module, fmt, arg1, arg2) \
531 if (!DEBUG(module)) (void)0; \
532 else debug_printf(fmt, arg1, arg2)
533
534 #define DEBUG3(module, fmt, arg1, arg2, arg3) \
535 if (!DEBUG(module)) (void)0; \
536 else debug_printf(fmt, arg1, arg2, arg3)
537
538 #define DEBUG4(module, fmt, arg1, arg2, arg3, arg4) \
539 if (!DEBUG(module)) (void)0; \
540 else debug_printf(fmt, arg1, arg2, arg3, arg4)
541
542 #define DEBUG5(module, fmt, arg1, arg2, arg3, arg4, arg5) \
543 if (!DEBUG(module)) (void)0; \
544 else debug_printf(fmt, arg1, arg2, arg3, arg4, arg5)
545
546 #include "nonints.h"
547
548 void Make_TimeStamp(GNode *, GNode *);
549 Boolean Make_OODate(GNode *);
550 void Make_ExpandUse(GNodeList *);
551 time_t Make_Recheck(GNode *);
552 void Make_HandleUse(GNode *, GNode *);
553 void Make_Update(GNode *);
554 void Make_DoAllVar(GNode *);
555 Boolean Make_Run(GNodeList *);
556 int dieQuietly(GNode *, int);
557 void PrintOnError(GNode *, const char *);
558 void Main_ExportMAKEFLAGS(Boolean);
559 Boolean Main_SetObjdir(const char *, ...) MAKE_ATTR_PRINTFLIKE(1, 2);
560 int mkTempFile(const char *, char **);
561 int str2Lst_Append(StringList *, char *, const char *);
562 void GNode_FprintDetails(FILE *, const char *, const GNode *, const char *);
563
564 static Boolean MAKE_ATTR_UNUSED
565 NoExecute(GNode *gn)
566 {
567 return (gn->type & OP_MAKE) ? noRecursiveExecute : noExecute;
568 }
569
570 /*
571 * See if the node with the given type was not the object of a dependency
572 * operator.
573 */
574 static Boolean MAKE_ATTR_UNUSED
575 OP_NOP(GNodeType t)
576 {
577 return !(t & OP_OPMASK);
578 }
579
580 #ifdef __GNUC__
581 #define UNCONST(ptr) ({ \
582 union __unconst { \
583 const void *__cp; \
584 void *__p; \
585 } __d; \
586 __d.__cp = ptr, __d.__p; })
587 #else
588 #define UNCONST(ptr) (void *)(ptr)
589 #endif
590
591 #ifndef MIN
592 #define MIN(a, b) (((a) < (b)) ? (a) : (b))
593 #endif
594 #ifndef MAX
595 #define MAX(a, b) (((a) > (b)) ? (a) : (b))
596 #endif
597
598 /* At least GNU/Hurd systems lack hardcoded MAXPATHLEN/PATH_MAX */
599 #include <limits.h>
600 #ifndef MAXPATHLEN
601 #define MAXPATHLEN 4096
602 #endif
603 #ifndef PATH_MAX
604 #define PATH_MAX MAXPATHLEN
605 #endif
606
607 #if defined(SYSV)
608 #define KILLPG(pid, sig) kill(-(pid), (sig))
609 #else
610 #define KILLPG(pid, sig) killpg((pid), (sig))
611 #endif
612
613 static inline MAKE_ATTR_UNUSED Boolean ch_isalnum(char ch)
614 { return isalnum((unsigned char)ch) != 0; }
615 static inline MAKE_ATTR_UNUSED Boolean ch_isalpha(char ch)
616 { return isalpha((unsigned char)ch) != 0; }
617 static inline MAKE_ATTR_UNUSED Boolean ch_isdigit(char ch)
618 { return isdigit((unsigned char)ch) != 0; }
619 static inline MAKE_ATTR_UNUSED Boolean ch_isspace(char ch)
620 { return isspace((unsigned char)ch) != 0; }
621 static inline MAKE_ATTR_UNUSED Boolean ch_isupper(char ch)
622 { return isupper((unsigned char)ch) != 0; }
623 static inline MAKE_ATTR_UNUSED char ch_tolower(char ch)
624 { return (char)tolower((unsigned char)ch); }
625 static inline MAKE_ATTR_UNUSED char ch_toupper(char ch)
626 { return (char)toupper((unsigned char)ch); }
627
628 static inline MAKE_ATTR_UNUSED void
629 cpp_skip_whitespace(const char **pp)
630 {
631 while (ch_isspace(**pp))
632 (*pp)++;
633 }
634
635 static inline MAKE_ATTR_UNUSED void
636 pp_skip_whitespace(char **pp)
637 {
638 while (ch_isspace(**pp))
639 (*pp)++;
640 }
641
642 #ifndef MAKE_NATIVE
643 #define MAKE_RCSID(id) static volatile char rcsid[] = id
644 #else
645 #include <sys/cdefs.h>
646 #ifndef lint
647 #define MAKE_RCSID(id) __RCSID(id)
648 #endif
649 #endif
650
651 #endif /* MAKE_MAKE_H */
652