Print this page
make: unifdef for NSE (undefined)
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/cmd/make/include/mksh/defs.h
+++ new/usr/src/cmd/make/include/mksh/defs.h
1 1 #ifndef _MKSH_DEFS_H
2 2 #define _MKSH_DEFS_H
3 3 /*
4 4 * CDDL HEADER START
5 5 *
6 6 * The contents of this file are subject to the terms of the
7 7 * Common Development and Distribution License (the "License").
8 8 * You may not use this file except in compliance with the License.
9 9 *
10 10 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
11 11 * or http://www.opensolaris.org/os/licensing.
12 12 * See the License for the specific language governing permissions
13 13 * and limitations under the License.
14 14 *
15 15 * When distributing Covered Code, include this CDDL HEADER in each
16 16 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
17 17 * If applicable, add the following below this CDDL HEADER, with the
18 18 * fields enclosed by brackets "[]" replaced with your own identifying
19 19 * information: Portions Copyright [yyyy] [name of copyright owner]
20 20 *
21 21 * CDDL HEADER END
22 22 */
23 23 /*
24 24 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
25 25 * Use is subject to license terms.
26 26 */
27 27
28 28 /*
29 29 * This is not "#ifdef TEAMWARE_MAKE_CMN" because we're currently
30 30 * using the TW fake i18n headers and libraries to build both
31 31 * SMake and PMake on SPARC/S1 and x86/S2.
32 32 */
33 33
34 34 #include <avo/intl.h>
35 35 #include <limits.h> /* MB_LEN_MAX */
36 36 #include <stdio.h>
37 37 #include <stdlib.h> /* wchar_t */
38 38 #include <string.h> /* strcmp() */
39 39 #include <nl_types.h> /* catgets() */
40 40 #include <sys/param.h> /* MAXPATHLEN */
41 41 #include <sys/types.h> /* time_t, caddr_t */
42 42 #include <vroot/vroot.h> /* pathpt */
43 43 #include <sys/time.h> /* timestruc_t */
44 44 #include <errno.h> /* errno */
45 45
46 46 #include <wctype.h>
47 47 #include <widec.h>
48 48
49 49
50 50 /*
51 51 * A type and some utilities for boolean values
52 52 */
53 53
54 54 #define false BOOLEAN_false
55 55 #define true BOOLEAN_true
56 56
57 57 typedef enum {
58 58 false = 0,
59 59 true = 1,
60 60 failed = 0,
61 61 succeeded = 1
62 62 } Boolean;
63 63 #define BOOLEAN(expr) ((expr) ? true : false)
64 64
65 65 /*
66 66 * Some random constants (in an enum so dbx knows their values)
67 67 */
68 68 enum {
69 69 update_delay = 30, /* time between rstat checks */
70 70 ar_member_name_len = 1024,
71 71 hashsize = 2048 /* size of hash table */
72 72 };
73 73
74 74
75 75 /*
76 76 * Symbols that defines all the different char constants make uses
77 77 */
78 78 enum {
79 79 ampersand_char = '&',
80 80 asterisk_char = '*',
81 81 at_char = '@',
82 82 backquote_char = '`',
83 83 backslash_char = '\\',
84 84 bar_char = '|',
85 85 braceleft_char = '{',
86 86 braceright_char = '}',
87 87 bracketleft_char = '[',
88 88 bracketright_char = ']',
89 89 colon_char = ':',
90 90 comma_char = ',',
91 91 dollar_char = '$',
92 92 doublequote_char = '"',
93 93 equal_char = '=',
94 94 exclam_char = '!',
95 95 greater_char = '>',
96 96 hat_char = '^',
97 97 hyphen_char = '-',
98 98 less_char = '<',
99 99 newline_char = '\n',
100 100 nul_char = '\0',
101 101 numbersign_char = '#',
102 102 parenleft_char = '(',
103 103 parenright_char = ')',
104 104 percent_char = '%',
105 105 period_char = '.',
106 106 plus_char = '+',
107 107 question_char = '?',
108 108 quote_char = '\'',
109 109 semicolon_char = ';',
110 110 slash_char = '/',
111 111 space_char = ' ',
112 112 tab_char = '\t',
113 113 tilde_char = '~'
114 114 };
115 115
116 116 /*
117 117 * For make i18n. Codeset independent.
118 118 * Setup character semantics by identifying all the special characters
119 119 * of make, and assigning each an entry in the char_semantics[] vector.
120 120 */
121 121 enum {
122 122 ampersand_char_entry = 0, /* 0 */
123 123 asterisk_char_entry, /* 1 */
124 124 at_char_entry, /* 2 */
125 125 backquote_char_entry, /* 3 */
126 126 backslash_char_entry, /* 4 */
127 127 bar_char_entry, /* 5 */
128 128 bracketleft_char_entry, /* 6 */
129 129 bracketright_char_entry, /* 7 */
130 130 colon_char_entry, /* 8 */
131 131 dollar_char_entry, /* 9 */
132 132 doublequote_char_entry, /* 10 */
133 133 equal_char_entry, /* 11 */
134 134 exclam_char_entry, /* 12 */
135 135 greater_char_entry, /* 13 */
136 136 hat_char_entry, /* 14 */
137 137 hyphen_char_entry, /* 15 */
138 138 less_char_entry, /* 16 */
139 139 newline_char_entry, /* 17 */
140 140 numbersign_char_entry, /* 18 */
141 141 parenleft_char_entry, /* 19 */
142 142 parenright_char_entry, /* 20 */
143 143 percent_char_entry, /* 21 */
144 144 plus_char_entry, /* 22 */
145 145 question_char_entry, /* 23 */
146 146 quote_char_entry, /* 24 */
147 147 semicolon_char_entry, /* 25 */
148 148 #ifdef SGE_SUPPORT
149 149 space_char_entry, /* 26 */
150 150 tab_char_entry, /* 27 */
151 151 no_semantics_entry /* 28 */
152 152 #else
153 153 no_semantics_entry /* 26 */
154 154 #endif /* SGE_SUPPORT */
155 155 };
156 156
157 157 /*
158 158 * CHAR_SEMANTICS_ENTRIES should be the number of entries above.
159 159 * The last entry in char_semantics[] should be blank.
160 160 */
161 161 #ifdef SGE_SUPPORT
162 162 #define CHAR_SEMANTICS_ENTRIES 29
163 163 /*
164 164 #define CHAR_SEMANTICS_STRING "&*@`\\|[]:$=!>-\n#()%+?;^<'\" \t"
165 165 */
166 166 #else
167 167 #define CHAR_SEMANTICS_ENTRIES 27
168 168 /*
169 169 #define CHAR_SEMANTICS_STRING "&*@`\\|[]:$=!>-\n#()%+?;^<'\""
170 170 */
171 171 #endif /* SGE_SUPPORT */
172 172
173 173 /*
174 174 * Some utility macros
175 175 */
176 176 #define ALLOC(x) ((struct _##x *)getmem(sizeof (struct _##x)))
177 177 #define ALLOC_WC(x) ((wchar_t *)getmem((x) * SIZEOFWCHAR_T))
178 178 #define FIND_LENGTH -1
179 179 #define GETNAME(a,b) getname_fn((a), (b), false)
180 180 #define IS_EQUAL(a,b) (!strcmp((a), (b)))
181 181 #define IS_EQUALN(a,b,n) (!strncmp((a), (b), (n)))
182 182 #define IS_WEQUAL(a,b) (!wscmp((a), (b)))
183 183 #define IS_WEQUALN(a,b,n) (!wsncmp((a), (b), (n)))
184 184 #define MBLEN(a) mblen((a), MB_LEN_MAX)
185 185 #define MBSTOWCS(a,b) (void) mbstowcs_with_check((a), (b), MAXPATHLEN)
186 186 #define MBTOWC(a,b) mbtowc((a), (b), MB_LEN_MAX)
187 187 #define SIZEOFWCHAR_T (sizeof (wchar_t))
188 188 #define VSIZEOF(v) (sizeof (v) / sizeof ((v)[0]))
189 189 #define WCSTOMBS(a,b) (void) wcstombs((a), (b), (MAXPATHLEN * MB_LEN_MAX))
190 190 #define WCTOMB(a,b) (void) wctomb((a), (b))
191 191 #define HASH(v, c) (v = (v)*31 + (unsigned int)(c))
192 192
193 193 extern void mbstowcs_with_check(wchar_t *pwcs, const char *s, size_t n);
194 194
195 195 /*
196 196 * Bits stored in funny vector to classify chars
197 197 */
198 198 enum {
199 199 dollar_sem = 0001,
200 200 meta_sem = 0002,
201 201 percent_sem = 0004,
202 202 wildcard_sem = 0010,
203 203 command_prefix_sem = 0020,
204 204 special_macro_sem = 0040,
205 205 colon_sem = 0100,
206 206 parenleft_sem = 0200
207 207 };
208 208
209 209 /*
210 210 * Type returned from doname class functions
211 211 */
212 212 typedef enum {
213 213 build_dont_know = 0,
214 214 build_failed,
215 215 build_ok,
216 216 build_in_progress,
217 217 build_running, /* PARALLEL & DISTRIBUTED */
218 218 build_pending, /* PARALLEL & DISTRIBUTED */
219 219 build_serial, /* PARALLEL & DISTRIBUTED */
220 220 build_subtree /* PARALLEL & DISTRIBUTED */
221 221 } Doname;
222 222
223 223 /*
224 224 * The String struct defines a string with the following layout
225 225 * "xxxxxxxxxxxxxxxCxxxxxxxxxxxxxxx________"
226 226 * ^ ^ ^ ^
227 227 * | | | |
228 228 * buffer.start text.p text.end buffer.end
229 229 * text.p points to the next char to read/write.
230 230 */
231 231 struct _String {
232 232 struct Text {
233 233 wchar_t *p; /* Read/Write pointer */
234 234 wchar_t *end; /* Read limit pointer */
235 235 } text;
236 236 struct Physical_buffer {
237 237 wchar_t *start; /* Points to start of buffer */
238 238 wchar_t *end; /* End of physical buffer */
239 239 } buffer;
240 240 Boolean free_after_use:1;
241 241 };
242 242
243 243 #define STRING_BUFFER_LENGTH 1024
244 244 #define INIT_STRING_FROM_STACK(str, buf) { \
245 245 str.buffer.start = (buf); \
246 246 str.text.p = (buf); \
247 247 str.text.end = NULL; \
248 248 str.buffer.end = (buf) \
249 249 + (sizeof (buf)/SIZEOFWCHAR_T); \
250 250 str.free_after_use = false; \
251 251 }
252 252
253 253 #define APPEND_NAME(np, dest, len) append_string((np)->string_mb, (dest), (len));
254 254
255 255 class Wstring {
256 256 public:
257 257 struct _String string;
258 258 wchar_t string_buf[STRING_BUFFER_LENGTH];
259 259
260 260 public:
261 261 Wstring();
262 262 Wstring(struct _Name * name);
263 263 ~Wstring();
264 264
265 265 void init(struct _Name * name);
266 266 void init(wchar_t * name, unsigned length);
267 267 unsigned length() {
268 268 return wslen(string.buffer.start);
269 269 };
270 270 void append_to_str(struct _String * str, unsigned off, unsigned length);
271 271
272 272 wchar_t * get_string() {
273 273 return string.buffer.start;
274 274 };
275 275
276 276 wchar_t * get_string(unsigned off) {
277 277 return string.buffer.start + off;
278 278 };
279 279
280 280 Boolean equaln(wchar_t * str, unsigned length);
281 281 Boolean equal(wchar_t * str);
282 282 Boolean equal(wchar_t * str, unsigned off);
283 283 Boolean equal(wchar_t * str, unsigned off, unsigned length);
284 284
285 285 Boolean equaln(Wstring * str, unsigned length);
286 286 Boolean equal(Wstring * str);
287 287 Boolean equal(Wstring * str, unsigned off);
288 288 Boolean equal(Wstring * str, unsigned off, unsigned length);
289 289 };
290 290
291 291
292 292 /*
293 293 * Used for storing the $? list and also for the "target + target:"
294 294 * construct.
295 295 */
296 296 struct _Chain {
297 297 struct _Chain *next;
298 298 struct _Name *name;
299 299 struct _Percent *percent_member;
300 300 };
301 301
302 302 /*
303 303 * Stores one command line for a rule
304 304 */
305 305 struct _Cmd_line {
306 306 struct _Cmd_line *next;
307 307 struct _Name *command_line;
308 308 Boolean make_refd:1; /* $(MAKE) referenced? */
309 309 /*
310 310 * Remember any command line prefixes given
311 311 */
312 312 Boolean ignore_command_dependency:1; /* `?' */
313 313 Boolean assign:1; /* `=' */
314 314 Boolean ignore_error:1; /* `-' */
315 315 Boolean silent:1; /* `@' */
316 316 Boolean always_exec:1; /* `+' */
317 317 };
318 318
319 319 /*
320 320 * Linked list of targets/files
321 321 */
322 322 struct _Dependency {
323 323 struct _Dependency *next;
324 324 struct _Name *name;
325 325 Boolean automatic:1;
326 326 Boolean stale:1;
↓ open down ↓ |
326 lines elided |
↑ open up ↑ |
327 327 Boolean built:1;
328 328 };
329 329
330 330 /*
331 331 * The specials are markers for targets that the reader should special case
332 332 */
333 333 typedef enum {
334 334 no_special,
335 335 built_last_make_run_special,
336 336 default_special,
337 -#ifdef NSE
338 - derived_src_special,
339 -#endif
340 337 get_posix_special,
341 338 get_special,
342 339 ignore_special,
343 340 keep_state_file_special,
344 341 keep_state_special,
345 342 make_version_special,
346 343 no_parallel_special,
347 344 parallel_special,
348 345 posix_special,
349 346 precious_special,
350 347 sccs_get_posix_special,
351 348 sccs_get_special,
352 349 silent_special,
353 350 suffixes_special,
354 351 svr4_special,
355 352 localhost_special
356 353 } Special;
357 354
358 355 typedef enum {
359 356 no_colon,
360 357 one_colon,
361 358 two_colon,
362 359 equal_seen,
363 360 conditional_seen,
364 361 none_seen
365 362 } Separator;
366 363
367 364 /*
368 365 * Magic values for the timestamp stored with each name object
369 366 */
370 367
371 368
372 369 extern const timestruc_t file_no_time;
373 370 extern const timestruc_t file_doesnt_exist;
374 371 extern const timestruc_t file_is_dir;
375 372 extern const timestruc_t file_min_time;
376 373 extern const timestruc_t file_max_time;
377 374
378 375 /*
379 376 * Each Name has a list of properties
380 377 * The properties are used to store information that only
381 378 * a subset of the Names need
382 379 */
383 380 typedef enum {
384 381 no_prop,
385 382 conditional_prop,
386 383 line_prop,
387 384 macro_prop,
388 385 makefile_prop,
389 386 member_prop,
390 387 recursive_prop,
391 388 sccs_prop,
392 389 suffix_prop,
393 390 target_prop,
394 391 time_prop,
395 392 vpath_alias_prop,
396 393 long_member_name_prop,
397 394 macro_append_prop,
398 395 env_mem_prop
399 396 } Property_id;
400 397
401 398 typedef enum {
402 399 no_daemon = 0,
403 400 chain_daemon
404 401 } Daemon;
405 402
406 403 struct _Env_mem {
407 404 char *value;
408 405 };
409 406
410 407 struct _Macro_appendix {
↓ open down ↓ |
61 lines elided |
↑ open up ↑ |
411 408 struct _Name *value;
412 409 struct _Name *value_to_append;
413 410 };
414 411
415 412 struct _Macro {
416 413 /*
417 414 * For "ABC = xyz" constructs
418 415 * Name "ABC" get one macro prop
419 416 */
420 417 struct _Name *value;
421 -#ifdef NSE
422 - Boolean imported:1;
423 -#endif
424 418 Boolean exported:1;
425 419 Boolean read_only:1;
426 420 /*
427 421 * This macro is defined conditionally
428 422 */
429 423 Boolean is_conditional:1;
430 424 /*
431 425 * The list for $? is stored as a structured list that
432 426 * is translated into a string iff it is referenced.
433 427 * This is why some macro values need a daemon.
434 428 */
435 429 Daemon daemon:2;
436 430 };
437 431
438 432 struct _Macro_list {
439 433 struct _Macro_list *next;
440 434 char *macro_name;
441 435 char *value;
442 436 };
443 437
444 438 enum sccs_stat {
445 439 DONT_KNOW_SCCS = 0,
446 440 NO_SCCS,
447 441 HAS_SCCS
448 442 };
449 443
450 444 struct _Name {
451 445 struct _Property *prop; /* List of properties */
452 446 char *string_mb; /* Multi-byte name string */
453 447 struct {
454 448 unsigned int length;
↓ open down ↓ |
21 lines elided |
↑ open up ↑ |
455 449 } hash;
456 450 struct {
457 451 timestruc_t time; /* Modification */
458 452 int stat_errno; /* error from "stat" */
459 453 off_t size; /* Of file */
460 454 mode_t mode; /* Of file */
461 455 Boolean is_file:1;
462 456 Boolean is_dir:1;
463 457 Boolean is_sym_link:1;
464 458 Boolean is_precious:1;
465 -#ifdef NSE
466 - Boolean is_derived_src:1;
467 -#endif
468 459 enum sccs_stat has_sccs:2;
469 460 } stat;
470 461 /*
471 462 * Count instances of :: definitions for this target
472 463 */
473 464 short colon_splits;
474 465 /*
475 466 * We only clear the automatic depes once per target per report
476 467 */
477 468 short temp_file_number;
478 469 /*
479 470 * Count how many conditional macros this target has defined
480 471 */
481 472 short conditional_cnt;
482 473 /*
483 474 * A conditional macro was used when building this target
484 475 */
485 476 Boolean depends_on_conditional:1;
486 477 /*
487 478 * Pointer to list of conditional macros which were used to build
488 479 * this target
489 480 */
490 481 struct _Macro_list *conditional_macro_list;
491 482 Boolean has_member_depe:1;
492 483 Boolean is_member:1;
493 484 /*
494 485 * This target is a directory that has been read
495 486 */
496 487 Boolean has_read_dir:1;
497 488 /*
498 489 * This name is a macro that is now being expanded
499 490 */
500 491 Boolean being_expanded:1;
501 492 /*
502 493 * This name is a magic name that the reader must know about
503 494 */
504 495 Special special_reader:5;
505 496 Doname state:3;
506 497 Separator colons:3;
507 498 Boolean has_depe_list_expanded:1;
508 499 Boolean suffix_scan_done:1;
509 500 Boolean has_complained:1; /* For sccs */
510 501 /*
511 502 * This target has been built during this make run
512 503 */
513 504 Boolean ran_command:1;
514 505 Boolean with_squiggle:1; /* for .SUFFIXES */
515 506 Boolean without_squiggle:1; /* for .SUFFIXES */
516 507 Boolean has_read_suffixes:1; /* Suffix list cached*/
517 508 Boolean has_suffixes:1;
518 509 Boolean has_target_prop:1;
519 510 Boolean has_vpath_alias_prop:1;
520 511 Boolean dependency_printed:1; /* For dump_make_state() */
521 512 Boolean dollar:1; /* In namestring */
522 513 Boolean meta:1; /* In namestring */
523 514 Boolean percent:1; /* In namestring */
524 515 Boolean wildcard:1; /* In namestring */
525 516 Boolean has_parent:1;
526 517 Boolean is_target:1;
527 518 Boolean has_built:1;
528 519 Boolean colon:1; /* In namestring */
529 520 Boolean parenleft:1; /* In namestring */
530 521 Boolean has_recursive_dependency:1;
531 522 Boolean has_regular_dependency:1;
532 523 Boolean is_double_colon:1;
533 524 Boolean is_double_colon_parent:1;
534 525 Boolean has_long_member_name:1;
535 526 /*
536 527 * allowed to run in parallel
537 528 */
538 529 Boolean parallel:1;
539 530 /*
540 531 * not allowed to run in parallel
541 532 */
542 533 Boolean no_parallel:1;
543 534 /*
544 535 * used in dependency_conflict
545 536 */
546 537 Boolean checking_subtree:1;
547 538 Boolean added_pattern_conditionals:1;
548 539 /*
549 540 * rechecking target for possible rebuild
550 541 */
551 542 Boolean rechecking_target:1;
552 543 /*
553 544 * build this target in silent mode
554 545 */
555 546 Boolean silent_mode:1;
556 547 /*
557 548 * build this target in ignore error mode
558 549 */
559 550 Boolean ignore_error_mode:1;
560 551 Boolean dont_activate_cond_values:1;
561 552 /*
562 553 * allowed to run serially on local host
563 554 */
564 555 Boolean localhost:1;
565 556 };
566 557
567 558 /*
568 559 * Stores the % matched default rules
569 560 */
570 561 struct _Percent {
571 562 struct _Percent *next;
572 563 struct _Name **patterns;
573 564 struct _Name *name;
574 565 struct _Percent *dependencies;
575 566 struct _Cmd_line *command_template;
576 567 struct _Chain *target_group;
577 568 int patterns_total;
578 569 Boolean being_expanded;
579 570 };
580 571
581 572 struct Conditional {
582 573 /*
583 574 * For "foo := ABC [+]= xyz" constructs
584 575 * Name "foo" gets one conditional prop
585 576 */
586 577 struct _Name *target;
587 578 struct _Name *name;
588 579 struct _Name *value;
589 580 int sequence;
590 581 Boolean append:1;
591 582 };
592 583
593 584 struct Line {
594 585 /*
595 586 * For "target : dependencies" constructs
596 587 * Name "target" gets one line prop
597 588 */
598 589 struct _Cmd_line *command_template;
599 590 struct _Cmd_line *command_used;
600 591 struct _Dependency *dependencies;
601 592 timestruc_t dependency_time;
602 593 struct _Chain *target_group;
603 594 Boolean is_out_of_date:1;
604 595 Boolean sccs_command:1;
605 596 Boolean command_template_redefined:1;
606 597 Boolean dont_rebuild_command_used:1;
607 598 /*
608 599 * Values for the dynamic macros
609 600 */
610 601 struct _Name *target;
611 602 struct _Name *star;
612 603 struct _Name *less;
613 604 struct _Name *percent;
614 605 struct _Chain *query;
615 606 };
616 607
617 608 struct Makefile {
618 609 /*
619 610 * Names that reference makefiles gets one prop
620 611 */
621 612 wchar_t *contents;
622 613 off_t size;
623 614 };
624 615
625 616 struct Member {
626 617 /*
627 618 * For "lib(member)" and "lib((entry))" constructs
628 619 * Name "lib(member)" gets one member prop
629 620 * Name "lib((entry))" gets one member prop
630 621 * The member field is filled in when the prop is refd
631 622 */
632 623 struct _Name *library;
633 624 struct _Name *entry;
634 625 struct _Name *member;
635 626 };
636 627
637 628 struct Recursive {
638 629 /*
639 630 * For "target: .RECURSIVE dir makefiles" constructs
640 631 * Used to keep track of recursive calls to make
641 632 * Name "target" gets one recursive prop
642 633 */
643 634 struct _Name *directory;
644 635 struct _Name *target;
645 636 struct _Dependency *makefiles;
646 637 Boolean has_built;
647 638 Boolean in_depinfo;
648 639 };
649 640
650 641 struct Sccs {
651 642 /*
652 643 * Each file that has a SCCS s. file gets one prop
653 644 */
654 645 struct _Name *file;
655 646 };
656 647
657 648 struct Suffix {
658 649 /*
659 650 * Cached list of suffixes that can build this target
660 651 * suffix is built from .SUFFIXES
661 652 */
662 653 struct _Name *suffix;
663 654 struct _Cmd_line *command_template;
664 655 };
665 656
666 657 struct Target {
667 658 /*
668 659 * For "target:: dependencies" constructs
669 660 * The "::" construct is handled by converting it to
670 661 * "foo: 1@foo" + "1@foo: dependecies"
671 662 * "1@foo" gets one target prop
672 663 * This target prop cause $@ to be bound to "foo"
673 664 * not "1@foo" when the rule is evaluated
674 665 */
675 666 struct _Name *target;
676 667 };
677 668
678 669 struct STime {
679 670 /*
680 671 * Save the original time for :: targets
681 672 */
682 673 timestruc_t time;
683 674 };
684 675
685 676 struct Vpath_alias {
686 677 /*
687 678 * If a file was found using the VPATH it gets
688 679 * a vpath_alias prop
689 680 */
690 681 struct _Name *alias;
691 682 };
692 683
693 684 struct Long_member_name {
694 685 /*
695 686 * Targets with a truncated member name carries
696 687 * the full lib(member) name for the state file
697 688 */
698 689 struct _Name *member_name;
699 690 };
700 691
701 692 union Body {
702 693 struct _Macro macro;
703 694 struct Conditional conditional;
704 695 struct Line line;
705 696 struct Makefile makefile;
706 697 struct Member member;
707 698 struct Recursive recursive;
708 699 struct Sccs sccs;
709 700 struct Suffix suffix;
710 701 struct Target target;
711 702 struct STime time;
712 703 struct Vpath_alias vpath_alias;
713 704 struct Long_member_name long_member_name;
714 705 struct _Macro_appendix macro_appendix;
715 706 struct _Env_mem env_mem;
716 707 };
717 708
718 709 #define PROPERTY_HEAD_SIZE (sizeof (struct _Property)-sizeof (union Body))
719 710 struct _Property {
720 711 struct _Property *next;
721 712 Property_id type:4;
722 713 union Body body;
723 714 };
724 715
725 716 /* Structure for dynamic "ascii" arrays */
726 717 struct ASCII_Dyn_Array {
727 718 char *start;
728 719 size_t size;
729 720 };
730 721
731 722 struct _Envvar {
732 723 struct _Name *name;
733 724 struct _Name *value;
734 725 struct _Envvar *next;
735 726 char *env_string;
736 727 Boolean already_put:1;
737 728 };
738 729
739 730 /*
740 731 * Macros for the reader
741 732 */
742 733 #define GOTO_STATE(new_state) { \
743 734 SET_STATE(new_state); \
744 735 goto enter_state; \
745 736 }
746 737 #define SET_STATE(new_state) state = (new_state)
747 738
748 739 #define UNCACHE_SOURCE() if (source != NULL) { \
749 740 source->string.text.p = source_p; \
750 741 }
751 742 #define CACHE_SOURCE(comp) if (source != NULL) { \
752 743 source_p = source->string.text.p - \
753 744 (comp); \
754 745 source_end = source->string.text.end; \
755 746 }
756 747 #define GET_NEXT_BLOCK_NOCHK(source) { UNCACHE_SOURCE(); \
757 748 source = get_next_block_fn(source); \
758 749 CACHE_SOURCE(0) \
759 750 }
760 751 #define GET_NEXT_BLOCK(source) { GET_NEXT_BLOCK_NOCHK(source); \
761 752 if (source != NULL && source->error_converting) { \
762 753 GOTO_STATE(illegal_bytes_state); \
763 754 } \
764 755 }
765 756 #define GET_CHAR() ((source == NULL) || \
766 757 (source_p >= source_end) ? 0 : *source_p)
767 758
768 759 struct _Source {
769 760 struct _String string;
770 761 struct _Source *previous;
771 762 off_t bytes_left_in_file;
772 763 short fd;
773 764 Boolean already_expanded:1;
774 765 Boolean error_converting:1;
775 766 char *inp_buf;
776 767 char *inp_buf_end;
777 768 char *inp_buf_ptr;
778 769 };
779 770
780 771 typedef enum {
781 772 reading_nothing,
782 773 reading_makefile,
783 774 reading_statefile,
784 775 rereading_statefile,
785 776 reading_cpp_file
786 777 } Makefile_type;
787 778
788 779 /*
789 780 * Typedefs for all structs
790 781 */
791 782 typedef struct _Chain *Chain, Chain_rec;
792 783 typedef struct _Envvar *Envvar, Envvar_rec;
793 784 typedef struct _Macro_list *Macro_list, Macro_list_rec;
794 785 typedef struct _Name *Name, Name_rec;
795 786 typedef struct _Property *Property, Property_rec;
796 787 typedef struct _Source *Source, Source_rec;
797 788 typedef struct _String *String, String_rec;
798 789
799 790 /*
800 791 * name records hash table.
801 792 */
802 793 struct Name_set {
803 794 private:
804 795 // single node in a tree
805 796 struct entry {
806 797 entry(Name name_, entry *parent_) :
807 798 name(name_),
808 799 parent(parent_),
809 800 left(0),
810 801 right(0),
811 802 depth(1)
812 803 {}
813 804
814 805 Name name;
815 806
816 807 entry *parent;
817 808 entry *left;
818 809 entry *right;
819 810 unsigned depth;
820 811
821 812 void setup_depth() {
822 813 unsigned rdepth = (right != 0) ? right->depth : 0;
823 814 unsigned ldepth = (left != 0) ? left->depth : 0;
824 815 depth = 1 + ((ldepth > rdepth) ? ldepth : rdepth);
825 816 }
826 817 };
827 818
828 819 public:
829 820 // make iterator a friend of Name_set to have access to struct entry
830 821 struct iterator;
831 822 friend struct Name_set::iterator;
832 823
833 824 // iterator over tree nodes
834 825 struct iterator {
835 826 public:
836 827 // constructors
837 828 iterator() : node(0) {}
838 829 iterator(entry *node_) : node(node_) {}
839 830
840 831 // dereference operator
841 832 Name operator->() const { return node->name; }
842 833
843 834 // conversion operator
844 835 operator Name() { return node->name; }
845 836
846 837 // assignment operator
847 838 iterator& operator=(const iterator &o) { node = o.node; return *this; }
848 839
849 840 // equality/inequality operators
850 841 int operator==(const iterator &o) const { return (node == o.node); }
851 842 int operator!=(const iterator &o) const { return (node != o.node); }
852 843
853 844 // pre/post increment operators
854 845 iterator& operator++();
855 846 iterator operator++(int) { iterator it = *this; ++*this; return it; }
856 847
857 848 private:
858 849 // the node iterator points to
859 850 entry *node;
860 851 };
861 852
862 853 public:
863 854 // constructor
864 855 Name_set() : root(0) {}
865 856
866 857 // lookup, insert and remove operations
867 858 Name lookup(const char *key);
868 859 Name insert(const char *key, Boolean &found);
869 860 void insert(Name name);
870 861
871 862 // begin/end iterators
872 863 iterator begin() const;
873 864 iterator end() const { return iterator(); }
874 865
875 866 private:
876 867 // rebalance given node
877 868 void rebalance(entry *node);
878 869
879 870 private:
880 871 // tree root
881 872 entry *root;
882 873 };
883 874
884 875 /*
885 876 * extern declarations for all global variables.
886 877 * The actual declarations are in globals.cc
887 878 */
888 879 extern char char_semantics[];
889 880 extern wchar_t char_semantics_char[];
890 881 extern Macro_list cond_macro_list;
891 882 extern Boolean conditional_macro_used;
892 883 extern Boolean do_not_exec_rule; /* `-n' */
893 884 extern Boolean dollarget_seen;
894 885 extern Boolean dollarless_flag;
895 886 extern Name dollarless_value;
896 887 extern char **environ;
897 888 extern Envvar envvar;
898 889 extern int exit_status;
899 890 extern wchar_t *file_being_read;
900 891 /* Variable gnu_style=true if env. var. SUN_MAKE_COMPAT_MODE=GNU (RFE 4866328) */
901 892 extern Boolean gnu_style;
902 893 extern Name_set hashtab;
903 894 extern Name host_arch;
904 895 extern Name host_mach;
905 896 extern int line_number;
906 897 extern char *make_state_lockfile;
907 898 extern Boolean make_word_mentioned;
908 899 extern Makefile_type makefile_type;
909 900 extern char mbs_buffer[];
910 901 extern Name path_name;
911 902 extern Boolean posix;
912 903 extern Name query;
913 904 extern Boolean query_mentioned;
914 905 extern Name hat;
915 906 extern Boolean reading_environment;
916 907 extern Name shell_name;
917 908 extern Boolean svr4;
918 909 extern Name target_arch;
919 910 extern Name target_mach;
920 911 extern Boolean tilde_rule;
921 912 extern wchar_t wcs_buffer[];
922 913 extern Boolean working_on_targets;
923 914 extern Name virtual_root;
924 915 extern Boolean vpath_defined;
925 916 extern Name vpath_name;
926 917 extern Boolean make_state_locked;
927 918 #if defined (TEAMWARE_MAKE_CMN) && defined(REDIRECT_ERR)
928 919 extern Boolean out_err_same;
929 920 #endif
930 921 extern pid_t childPid;
931 922 extern nl_catd libmksh_catd;
932 923
933 924 /*
934 925 * RFE 1257407: make does not use fine granularity time info available from stat.
935 926 * High resolution time comparison.
936 927 */
937 928
938 929 inline int
939 930 operator==(const timestruc_t &t1, const timestruc_t &t2) {
940 931 return ((t1.tv_sec == t2.tv_sec) && (t1.tv_nsec == t2.tv_nsec));
941 932 }
942 933
943 934 inline int
944 935 operator!=(const timestruc_t &t1, const timestruc_t &t2) {
945 936 return ((t1.tv_sec != t2.tv_sec) || (t1.tv_nsec != t2.tv_nsec));
946 937 }
947 938
948 939 inline int
949 940 operator>(const timestruc_t &t1, const timestruc_t &t2) {
950 941 if (t1.tv_sec == t2.tv_sec) {
951 942 return (t1.tv_nsec > t2.tv_nsec);
952 943 }
953 944 return (t1.tv_sec > t2.tv_sec);
954 945 }
955 946
956 947 inline int
957 948 operator>=(const timestruc_t &t1, const timestruc_t &t2) {
958 949 if (t1.tv_sec == t2.tv_sec) {
959 950 return (t1.tv_nsec >= t2.tv_nsec);
960 951 }
961 952 return (t1.tv_sec > t2.tv_sec);
962 953 }
963 954
964 955 inline int
965 956 operator<(const timestruc_t &t1, const timestruc_t &t2) {
966 957 if (t1.tv_sec == t2.tv_sec) {
967 958 return (t1.tv_nsec < t2.tv_nsec);
968 959 }
969 960 return (t1.tv_sec < t2.tv_sec);
970 961 }
971 962
972 963 inline int
973 964 operator<=(const timestruc_t &t1, const timestruc_t &t2) {
974 965 if (t1.tv_sec == t2.tv_sec) {
975 966 return (t1.tv_nsec <= t2.tv_nsec);
976 967 }
977 968 return (t1.tv_sec < t2.tv_sec);
978 969 }
979 970
980 971 #endif
↓ open down ↓ |
503 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX