[3138] | 1 | /* Output to stdout / stderr for GNU make
|
---|
| 2 | Copyright (C) 2013-2016 Free Software Foundation, Inc.
|
---|
| 3 | This file is part of GNU Make.
|
---|
| 4 |
|
---|
| 5 | GNU Make is free software; you can redistribute it and/or modify it under the
|
---|
| 6 | terms of the GNU General Public License as published by the Free Software
|
---|
| 7 | Foundation; either version 3 of the License, or (at your option) any later
|
---|
| 8 | version.
|
---|
| 9 |
|
---|
| 10 | GNU Make is distributed in the hope that it will be useful, but WITHOUT ANY
|
---|
| 11 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
---|
| 12 | A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
---|
| 13 |
|
---|
| 14 | You should have received a copy of the GNU General Public License along with
|
---|
| 15 | this program. If not, see <http://www.gnu.org/licenses/>. */
|
---|
| 16 |
|
---|
[3192] | 17 | #ifndef INCLUDED_MAKE_OUTPUT_H
|
---|
| 18 | #define INCLUDED_MAKE_OUTPUT_H
|
---|
[3230] | 19 | #include <stdio.h> /* darwin*/
|
---|
[3192] | 20 |
|
---|
[3189] | 21 | #ifdef CONFIG_WITH_OUTPUT_IN_MEMORY
|
---|
| 22 | /* Output run. */
|
---|
| 23 | struct output_run
|
---|
| 24 | {
|
---|
| 25 | unsigned int seqno; /* For interleaving out/err output. */
|
---|
| 26 | unsigned int len; /* The length of the output. */
|
---|
| 27 | struct output_run *next; /* Pointer to the next run. */
|
---|
| 28 | };
|
---|
| 29 |
|
---|
| 30 | /* Output segment. */
|
---|
| 31 | struct output_segment
|
---|
| 32 | {
|
---|
| 33 | struct output_segment *next;
|
---|
| 34 | size_t size; /* Segment size, everything included. */
|
---|
| 35 | struct output_run runs[1];
|
---|
| 36 | };
|
---|
| 37 |
|
---|
| 38 | /* Output memory buffer. */
|
---|
| 39 | struct output_membuf
|
---|
| 40 | {
|
---|
| 41 | struct output_run *head_run;
|
---|
| 42 | struct output_run *tail_run; /* Always in tail_seg. */
|
---|
| 43 | struct output_segment *head_seg;
|
---|
| 44 | struct output_segment *tail_seg;
|
---|
| 45 | size_t left; /* Number of bytes that can be appended to
|
---|
| 46 | the tail_run. */
|
---|
| 47 | size_t total; /* Total segment allocation size. */
|
---|
| 48 | };
|
---|
| 49 | #endif /* CONFIG_WITH_OUTPUT_IN_MEMORY */
|
---|
| 50 |
|
---|
[3138] | 51 | struct output
|
---|
| 52 | {
|
---|
[3189] | 53 | #ifdef CONFIG_WITH_OUTPUT_IN_MEMORY
|
---|
| 54 | struct output_membuf out;
|
---|
| 55 | struct output_membuf err;
|
---|
| 56 | unsigned int seqno; /* The current run sequence number. */
|
---|
| 57 | #else
|
---|
[3138] | 58 | int out;
|
---|
| 59 | int err;
|
---|
[3189] | 60 | #endif
|
---|
[3138] | 61 | unsigned int syncout:1; /* True if we want to synchronize output. */
|
---|
[3432] | 62 | #ifdef KMK
|
---|
| 63 | unsigned int dont_truncate:1; /* For die_with_child_output repeat. */
|
---|
| 64 | #endif
|
---|
[3138] | 65 | };
|
---|
| 66 |
|
---|
| 67 | extern struct output *output_context;
|
---|
| 68 | extern unsigned int stdio_traced;
|
---|
[3479] | 69 | #if defined(KMK) && !defined(NO_OUTPUT_SYNC)
|
---|
| 70 | extern int output_metered;
|
---|
| 71 | #endif
|
---|
[3138] | 72 |
|
---|
| 73 | #define OUTPUT_SET(_new) do{ output_context = (_new)->syncout ? (_new) : NULL; }while(0)
|
---|
| 74 | #define OUTPUT_UNSET() do{ output_context = NULL; }while(0)
|
---|
| 75 |
|
---|
| 76 | #define OUTPUT_TRACED() do{ stdio_traced = 1; }while(0)
|
---|
| 77 | #define OUTPUT_IS_TRACED() (!!stdio_traced)
|
---|
| 78 |
|
---|
| 79 | FILE *output_tmpfile (char **, const char *);
|
---|
| 80 |
|
---|
| 81 | /* Initialize and close a child output structure: if NULL do this program's
|
---|
| 82 | output (this should only be done once). */
|
---|
| 83 | void output_init (struct output *out);
|
---|
| 84 | void output_close (struct output *out);
|
---|
| 85 |
|
---|
| 86 | /* In situations where output may be about to be displayed but we're not
|
---|
| 87 | sure if we've set it up yet, call this. */
|
---|
| 88 | void output_start (void);
|
---|
| 89 |
|
---|
| 90 | /* Show a message on stdout or stderr. Will start the output if needed. */
|
---|
| 91 | void outputs (int is_err, const char *msg);
|
---|
[3190] | 92 | #ifdef CONFIG_WITH_OUTPUT_IN_MEMORY
|
---|
[3192] | 93 | ssize_t output_write_bin (struct output *out, int is_err, const char *src, size_t len);
|
---|
[3244] | 94 | #endif
|
---|
[3192] | 95 | ssize_t output_write_text (struct output *out, int is_err, const char *src, size_t len);
|
---|
[3138] | 96 |
|
---|
| 97 | #ifndef NO_OUTPUT_SYNC
|
---|
| 98 | int output_tmpfd (void);
|
---|
| 99 | /* Dump any child output content to stdout, and reset it. */
|
---|
| 100 | void output_dump (struct output *out);
|
---|
[3479] | 101 | # ifdef KMK
|
---|
| 102 | void output_reset (struct output *out);
|
---|
| 103 | # endif
|
---|
[3138] | 104 | #endif
|
---|
[3192] | 105 |
|
---|
[3666] | 106 | #ifdef DEBUG_STDOUT_CLOSE_ISSUE
|
---|
| 107 | void my_check_stdout (const char *pszWhere);
|
---|
| 108 | #endif
|
---|
| 109 |
|
---|
[3192] | 110 | #endif /* INLCUDED_MAKE_OUTPUT_H */
|
---|
| 111 |
|
---|