| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 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; |
| 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 |
|
| 41 |
|
| 42 |
int output_write (int fd, const void *buffer, size_t len); |
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
void output_init (struct output *out); |
| 47 |
void output_close (struct output *out); |
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
void output_start (void); |
| 52 |
|
| 53 |
|
| 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 |
|
| 69 |
void output_dump (struct output *out); |
| 70 |
|
| 71 |
# ifdef WINDOWS32 |
| 72 |
|
| 73 |
# define F_GETFD 1 |
| 74 |
# define F_SETLKW 2 |
| 75 |
|
| 76 |
|
| 77 |
|
| 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 |
|
| 91 |
|
| 92 |
typedef intptr_t sync_handle_t; |
| 93 |
|
| 94 |
|
| 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 |
| 105 |
|
| 106 |
typedef int sync_handle_t; |
| 107 |
|
| 108 |
# define RECORD_SYNC_MUTEX(m) (void)(m) |
| 109 |
|
| 110 |
# endif |
| 111 |
#endif |
| 112 |
|
| 113 |
#endif |