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