VirtualBox

source: kBuild/trunk/src/kmk/output.h@ 3219

Last change on this file since 3219 was 3192, checked in by bird, 6 years ago

kmkbuiltin: funnel output thru output.c (usually via err.c).

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

© 2023 Oracle
ContactPrivacy policyTerms of Use