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