Debian Codegraph @

src/output.h

raw symbols SCIP
1 /* Output to stdout / stderr for GNU make
2 Copyright (C) 2013-2020 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
17 #ifndef REMAKE_OUTPUT_H
18 #define REMAKE_OUTPUT_H
19
20 struct output
21 {
22 int out;
23 int err;
24 unsigned int syncout:1; /* True if we want to synchronize output. */
25 };
26
27 extern struct output *output_context;
28 extern unsigned int stdio_traced;
29
30 #define FD_STDIN (fileno (stdin))
31 #define FD_STDOUT (fileno (stdout))
32 #define FD_STDERR (fileno (stderr))
33
34 #define OUTPUT_SET(_new) do{ output_context = (_new)->syncout ? (_new) : NULL; }while(0)
35 #define OUTPUT_UNSET() do{ output_context = NULL; }while(0)
36
37 #define OUTPUT_TRACED() do{ stdio_traced = 1; }while(0)
38 #define OUTPUT_IS_TRACED() (!!stdio_traced)
39
40 /* Write a buffer directly to the given file descriptor.
41 This handles errors etc. */
42 int output_write (int fd, const void *buffer, size_t len);
43
44 /* Initialize and close a child output structure: if NULL do this program's
45 output (this should only be done once). */
46 void output_init (struct output *out);
47 void output_close (struct output *out);
48
49 /* In situations where output may be about to be displayed but we're not
50 sure if we've set it up yet, call this. */
51 void output_start (void);
52
53 /* Show a message on stdout or stderr. Will start the output if needed. */
54 void outputs (int is_err, const char *msg);
55
56 #if defined(HAVE_FCNTL_H)
57 # include <fcntl.h>
58 #elif defined(HAVE_SYS_FILE_H)
59 # include <sys/file.h>
60 #endif
61
62 #ifdef NO_OUTPUT_SYNC
63 # define RECORD_SYNC_MUTEX(m) \
64 O (error, NILF, \
65 _("-O[TYPE] (--output-sync[=TYPE]) is not configured for this build."));
66 #else
67 int output_tmpfd (void);
68 /* Dump any child output content to stdout, and reset it. */
69 void output_dump (struct output *out);
70
71 # ifdef WINDOWS32
72 /* For emulations in w32/compat/posixfcn.c. */
73 # define F_GETFD 1
74 # define F_SETLKW 2
75 /* Implementation note: None of the values of l_type below can be zero
76 -- they are compared with a static instance of the struct, so zero
77 means unknown/invalid, see w32/compat/posixfcn.c. */
78 # define F_WRLCK 1
79 # define F_UNLCK 2
80
81 struct flock
82 {
83 short l_type;
84 short l_whence;
85 off_t l_start;
86 off_t l_len;
87 pid_t l_pid;
88 };
89
90 /* This type is actually a HANDLE, but we want to avoid including
91 windows.h as much as possible. */
92 typedef intptr_t sync_handle_t;
93
94 /* Public functions emulated/provided in posixfcn.c. */
95 # if !defined(GNULIB_defined_rpl_fcntl) && !defined(GNULIB_defined_fcntl)
96 int fcntl (intptr_t fd, int cmd, ...);
97 # endif
98 intptr_t create_mutex (void);
99 int same_stream (FILE *f1, FILE *f2);
100
101 # define RECORD_SYNC_MUTEX(m) record_sync_mutex(m)
102 void record_sync_mutex (const char *str);
103 void prepare_mutex_handle_string (intptr_t hdl);
104 # else /* !WINDOWS32 */
105
106 typedef int sync_handle_t; /* file descriptor */
107
108 # define RECORD_SYNC_MUTEX(m) (void)(m)
109
110 # endif
111 #endif /* !NO_OUTPUT_SYNC */
112
113 #endif /*REMAKE_OUTPUT_H*/