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