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