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