* diagnostic.c (output_format): Add support for %m.
(output_printf, output_verbatim, diagnostic_set_info,
verbatim): Set err_no field of the text_info structure being
initialized.
(fatal_io_error): Delete function.
* diagnostic.h (text_info): Add err_no field.
* toplev.h (fatal_io_error): Delete prototype.
* c-opts.c, c-pch.c, dwarfout.c, ggc-common.c, ggc-page.c, graph.c
* toplev.c, config/mips/mips.c, config/rs6000/host-darwin.c
* f/com.c, java/jcf-parse.c, java/jcf-write.c, java/lex.c
* objc/objc-act.c: Replace all calls to fatal_io_error with
calls to fatal_error; add ": %m" to the end of all the affected
error messages.
From-SVN: r66769
+2003-05-13 Zack Weinberg <zack@codesourcery.com>
+
+ * diagnostic.c (output_format): Add support for %m.
+ (output_printf, output_verbatim, diagnostic_set_info,
+ verbatim): Set err_no field of the text_info structure being
+ initialized.
+ (fatal_io_error): Delete function.
+ * diagnostic.h (text_info): Add err_no field.
+ * toplev.h (fatal_io_error): Delete prototype.
+
+ * c-opts.c, c-pch.c, dwarfout.c, ggc-common.c, ggc-page.c, graph.c
+ * toplev.c, config/mips/mips.c, config/rs6000/host-darwin.c
+ * objc/objc-act.c: Replace all calls to fatal_io_error with
+ calls to fatal_error; add ": %m" to the end of all the affected
+ error messages.
+
2003-05-13 Zack Weinberg <zack@codesourcery.com>
* varasm.c (notice_rtl_inlining_of_deferred_constant): New function.
if (out_stream == NULL)
{
- fatal_io_error ("opening output file %s", out_fname);
+ fatal_error ("opening output file %s: %m", out_fname);
return false;
}
{
deps_stream = fopen (deps_file, deps_append ? "a": "w");
if (!deps_stream)
- fatal_io_error ("opening dependency file %s", deps_file);
+ fatal_error ("opening dependency file %s: %m", deps_file);
}
}
if (deps_stream && deps_stream != out_stream
&& (ferror (deps_stream) || fclose (deps_stream)))
- fatal_io_error ("closing dependency file %s", deps_file);
+ fatal_error ("closing dependency file %s: %m", deps_file);
if (out_stream && (ferror (out_stream) || fclose (out_stream)))
- fatal_io_error ("when writing output to %s", out_fname);
+ fatal_error ("when writing output to %s: %m", out_fname);
}
/* Either of two environment variables can specify output of
f = fopen (pch_file, "w+b");
if (f == NULL)
- fatal_io_error ("can't open %s", pch_file);
+ fatal_error ("can't open %s: %m", pch_file);
pch_outfile = f;
v.debug_info_type = write_symbols;
if (fwrite (get_ident(), IDENT_LENGTH, 1, f) != 1
|| fwrite (&v, sizeof (v), 1, f) != 1)
- fatal_io_error ("can't write to %s", pch_file);
+ fatal_error ("can't write to %s: %m", pch_file);
/* We need to be able to re-read the output. */
/* The driver always provides a valid -o option. */
h.asm_size = asm_file_end - asm_file_startpos;
if (fwrite (&h, sizeof (h), 1, pch_outfile) != 1)
- fatal_io_error ("can't write %s", pch_file);
+ fatal_error ("can't write %s: %m", pch_file);
buf = xmalloc (16384);
fflush (asm_out_file);
if (fseek (asm_out_file, asm_file_startpos, SEEK_SET) != 0)
- fatal_io_error ("can't seek in %s", asm_file_name);
+ fatal_error ("can't seek in %s: %m", asm_file_name);
for (written = asm_file_startpos; written < asm_file_end; )
{
if (size > 16384)
size = 16384;
if (fread (buf, size, 1, asm_out_file) != 1)
- fatal_io_error ("can't read %s", asm_file_name);
+ fatal_error ("can't read %s: %m", asm_file_name);
if (fwrite (buf, size, 1, pch_outfile) != 1)
- fatal_io_error ("can't write %s", pch_file);
+ fatal_error ("can't write %s: %m", pch_file);
written += size;
}
free (buf);
sizeread = read (fd, ident, IDENT_LENGTH);
if (sizeread == -1)
- {
- fatal_io_error ("can't read %s", name);
- return 2;
- }
+ fatal_error ("can't read %s: %m", name);
else if (sizeread != IDENT_LENGTH)
return 2;
}
if (read (fd, &v, sizeof (v)) != sizeof (v))
- {
- fatal_io_error ("can't read %s", name);
- return 2;
- }
+ fatal_error ("can't read %s: %m", name);
/* The allowable debug info combinations are that either the PCH file
was built with the same as is being used now, or the PCH file was
size_t len;
rewind (from);
if (ferror (from))
- fatal_io_error ("can't rewind temp file");
+ fatal_error ("can't rewind temp file: %m");
while ((len = fread (buffer, 1, sizeof (buffer), from)) > 0)
if (fwrite (buffer, 1, len, to) != len)
- fatal_io_error ("can't write to output file");
+ fatal_error ("can't write to output file: %m");
if (ferror (from))
- fatal_io_error ("can't read from temp file");
+ fatal_error ("can't read from temp file: %m");
if (fclose (from))
- fatal_io_error ("can't close temp file");
+ fatal_error ("can't close temp file: %m");
}
/* Emit either a label, .comm, or .lcomm directive, and mark that the symbol
sigstk.ss_size = SIGSTKSZ;
sigstk.ss_flags = 0;
if (sigaltstack (&sigstk, NULL) < 0)
- fatal_io_error ("While setting up signal stack");
+ fatal_error ("While setting up signal stack: %m");
sigemptyset(&sact.sa_mask);
sact.sa_flags = SA_ONSTACK | SA_SIGINFO;
sact.sa_sigaction = segv_handler;
if (sigaction (SIGSEGV, &sact, 0) < 0)
- fatal_io_error ("While setting up signal handler");
+ fatal_error ("While setting up signal handler: %m");
}
const struct host_hooks host_hooks = HOST_HOOKS_INITIALIZER;
%c: character.
%s: string.
%p: pointer.
+ %m: strerror(text->err_no) - does not consume a value from args_ptr.
%%: `%'.
%*.s: a substring the length of which is specified by an integer.
%H: location_t. */
++text->format_spec;
}
- /* Handle %c, %d, %i, %ld, %li, %lo, %lu, %lx, %o, %s, %u,
+ /* Handle %c, %d, %i, %ld, %li, %lo, %lu, %lx, %m, %o, %s, %u,
%x, %p, %.*s; %%. And nothing else. Front-ends should install
printers to grok language specific format specifiers. */
switch (*text->format_spec)
(buffer, va_arg (*text->args_ptr, unsigned int));
break;
+ case 'm':
+ output_add_string (buffer, xstrerror (text->err_no));
+ break;
+
case '%':
output_add_character (buffer, '%');
break;
VA_FIXEDARG (ap, output_buffer *, buffer);
VA_FIXEDARG (ap, const char *, msgid);
+ text.err_no = errno;
text.args_ptr = ≈
text.format_spec = _(msgid);
output_format (buffer, &text);
VA_FIXEDARG (ap, output_buffer *, buffer);
VA_FIXEDARG (ap, const char *, msgid);
- text.format_spec = msgid;
+ text.err_no = errno;
text.args_ptr = ≈
+ text.format_spec = _(msgid);
output_do_verbatim (buffer, &text);
VA_CLOSE (ap);
}
int line;
diagnostic_t kind;
{
- diagnostic->message.format_spec = _(msgid);
+ diagnostic->message.err_no = errno;
diagnostic->message.args_ptr = args;
+ diagnostic->message.format_spec = _(msgid);
/* If the diagnostic message doesn't specify a location,
use FILE and LINE. */
if (!text_specifies_location (&diagnostic->message, &diagnostic->location))
VA_OPEN (ap, msgid);
VA_FIXEDARG (ap, const char *, msgid);
- text.format_spec = _(msgid);
+ text.err_no = errno;
text.args_ptr = ≈
+ text.format_spec = _(msgid);
output_do_verbatim (&global_dc->buffer, &text);
output_buffer_to_stream (&global_dc->buffer);
VA_CLOSE (ap);
}
}
-/* Print a fatal I/O error message. Argument are like printf.
- Also include a system error message based on `errno'. */
-void
-fatal_io_error VPARAMS ((const char *msgid, ...))
-{
- text_info text;
- VA_OPEN (ap, msgid);
- VA_FIXEDARG (ap, const char *, msgid);
-
- text.format_spec = _(msgid);
- text.args_ptr = ≈
- output_printf (&global_dc->buffer, "%s: %s: ", progname, xstrerror (errno));
- output_format (&global_dc->buffer, &text);
- output_flush (&global_dc->buffer);
- VA_CLOSE (ap);
- exit (FATAL_EXIT_CODE);
-}
-
/* Inform the user that an error occurred while trying to report some
other error. This indicates catastrophic internal inconsistencies,
so give up now. But do try to flush out the previous error.
{
const char *format_spec;
va_list *args_ptr;
+ int err_no; /* for %m */
} text_info;
/* Contants used to discriminate diagnostics. */
char *dirname;
if (!pwd)
- fatal_io_error ("can't get current directory");
+ fatal_error ("can't get current directory: %m");
dirname = concat (pwd, "/", NULL);
ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file, dirname);
+2003-05-13 Zack Weinberg <zack@codesourcery.com>
+
+ * com.c: Replace all calls to fatal_io_error with calls to
+ fatal_error; add ": %m" to the end of all the affected error
+ messages.
+
2003-05-12 Zack Weinberg <zack@codesourcery.com>
* bad.c: Don't call diagnostic_count_diagnostic.
finput = fopen (filename, "r");
if (finput == 0)
- fatal_io_error ("can't open %s", filename);
+ fatal_error ("can't open %s: %m", filename);
return false;
}
{
if (fwrite (&ptr, sizeof (void *), 1, state->f)
!= 1)
- fatal_io_error ("can't write PCH file");
+ fatal_error ("can't write PCH file: %m");
}
else
{
POINTER_HASH (ptr));
if (fwrite (&new_ptr->new_addr, sizeof (void *), 1, state->f)
!= 1)
- fatal_io_error ("can't write PCH file");
+ fatal_error ("can't write PCH file: %m");
}
}
}
for (rt = gt_pch_scalar_rtab; *rt; rt++)
for (rti = *rt; rti->base != NULL; rti++)
if (fwrite (rti->base, rti->stride, 1, f) != 1)
- fatal_io_error ("can't write PCH file");
+ fatal_error ("can't write PCH file: %m");
/* Write out all the global pointers, after translation. */
write_pch_globals (gt_ggc_rtab, &state);
long o;
o = ftell (state.f) + sizeof (mmi);
if (o == -1)
- fatal_io_error ("can't get position in PCH file");
+ fatal_error ("can't get position in PCH file: %m");
mmi.offset = page_size - o % page_size;
if (mmi.offset == page_size)
mmi.offset = 0;
mmi.offset += o;
}
if (fwrite (&mmi, sizeof (mmi), 1, state.f) != 1)
- fatal_io_error ("can't write PCH file");
+ fatal_error ("can't write PCH file: %m");
if (mmi.offset != 0
&& fseek (state.f, mmi.offset, SEEK_SET) != 0)
- fatal_io_error ("can't write padding to PCH file");
+ fatal_error ("can't write padding to PCH file: %m");
/* Actually write out the objects. */
for (i = 0; i < state.count; i++)
for (rt = gt_pch_scalar_rtab; *rt; rt++)
for (rti = *rt; rti->base != NULL; rti++)
if (fread (rti->base, rti->stride, 1, f) != 1)
- fatal_io_error ("can't read PCH file");
+ fatal_error ("can't read PCH file: %m");
/* Read in all the global pointers, in 6 easy loops. */
for (rt = gt_ggc_rtab; *rt; rt++)
for (i = 0; i < rti->nelt; i++)
if (fread ((char *)rti->base + rti->stride * i,
sizeof (void *), 1, f) != 1)
- fatal_io_error ("can't read PCH file");
+ fatal_error ("can't read PCH file: %m");
for (rt = gt_pch_cache_rtab; *rt; rt++)
for (rti = *rt; rti->base != NULL; rti++)
for (i = 0; i < rti->nelt; i++)
if (fread ((char *)rti->base + rti->stride * i,
sizeof (void *), 1, f) != 1)
- fatal_io_error ("can't read PCH file");
+ fatal_error ("can't read PCH file: %m");
if (fread (&mmi, sizeof (mmi), 1, f) != 1)
- fatal_io_error ("can't read PCH file");
+ fatal_error ("can't read PCH file: %m");
#if HAVE_MMAP_FILE
addr = mmap (mmi.preferred_base, mmi.size,
addr = xmalloc (mmi.size);
if (fseek (f, mmi.offset, SEEK_SET) != 0
|| fread (&mmi, mmi.size, 1, f) != 1)
- fatal_io_error ("can't read PCH file");
+ fatal_error ("can't read PCH file: %m");
}
else if (fseek (f, mmi.offset + mmi.size, SEEK_SET) != 0)
- fatal_io_error ("can't read PCH file");
+ fatal_error ("can't read PCH file: %m");
ggc_pch_read (f, addr);
}
if (fwrite (x, size, 1, f) != 1)
- fatal_io_error ("can't write PCH file");
+ fatal_error ("can't write PCH file: %m");
/* In the current implementation, SIZE is always equal to
OBJECT_SIZE (order) and so the fseek is never executed. */
if (size != OBJECT_SIZE (order)
&& fseek (f, OBJECT_SIZE (order) - size, SEEK_CUR) != 0)
- fatal_io_error ("can't write PCH file");
+ fatal_error ("can't write PCH file: %m");
d->written[order]++;
if (d->written[order] == d->d.totals[order]
&& fseek (f, ROUND_UP_VALUE (d->d.totals[order] * OBJECT_SIZE (order),
G.pagesize),
SEEK_CUR) != 0)
- fatal_io_error ("can't write PCH file");
+ fatal_error ("can't write PCH file: %m");
}
void
FILE *f;
{
if (fwrite (&d->d, sizeof (d->d), 1, f) != 1)
- fatal_io_error ("can't write PCH file");
+ fatal_error ("can't write PCH file: %m");
free (d);
}
/* Allocate the appropriate page-table entries for the pages read from
the PCH file. */
if (fread (&d, sizeof (d), 1, f) != 1)
- fatal_io_error ("can't read PCH file");
+ fatal_error ("can't read PCH file: %m");
for (i = 0; i < NUM_ORDERS; i++)
{
fp = fopen (buf, "w");
if (fp == NULL)
- fatal_io_error ("can't open %s", buf);
+ fatal_error ("can't open %s: %m", buf);
switch (graph_dump_format)
{
+2003-05-13 Zack Weinberg <zack@codesourcery.com>
+
+ * jcf-parse.c, jcf-write.c, lex.c: Replace all calls to
+ fatal_io_error with calls to fatal_error; add ": %m" to the end of
+ all the affected error messages.
+
2003-05-13 Richard Henderson <rth@redhat.com>
* class.c (layout_class_method): Set DECL_EXTERNAL.
if (!HAS_BEEN_ALREADY_PARSED_P (file))
{
if (!(finput = fopen (input_filename, "r")))
- fatal_io_error ("can't reopen %s", input_filename);
+ fatal_error ("can't reopen %s: %m", input_filename);
parse_source_file_1 (file, finput);
parse_source_file_2 ();
parse_source_file_3 ();
if (fclose (finput))
- fatal_io_error ("can't close %s", input_filename);
+ fatal_error ("can't close %s: %m", input_filename);
}
JCF_FINISH (current_jcf);
java_pop_parser_context (generate);
int avail = 2000;
finput = fopen (input_filename, "r");
if (finput == NULL)
- fatal_io_error ("can't open %s", input_filename);
+ fatal_error ("can't open %s: %m", input_filename);
list = xmalloc(avail);
next = list;
for (;;)
if (count == 0)
{
if (! feof (finput))
- fatal_io_error ("error closing %s", input_filename);
+ fatal_error ("error closing %s: %m", input_filename);
*next = '\0';
break;
}
/* Close previous descriptor, if any */
if (finput && fclose (finput))
- fatal_io_error ("can't close input file %s", main_input_filename);
+ fatal_error ("can't close input file %s: %m", main_input_filename);
finput = fopen (IDENTIFIER_POINTER (name), "rb");
if (finput == NULL)
- fatal_io_error ("can't open %s", IDENTIFIER_POINTER (name));
+ fatal_error ("can't open %s: %m", IDENTIFIER_POINTER (name));
#ifdef IO_BUFFER_SIZE
setvbuf (finput, xmalloc (IO_BUFFER_SIZE),
if (stat (r, &sb) == -1
/* Try to make it. */
&& mkdir (r, 0755) == -1)
- fatal_io_error ("can't create directory %s", r);
+ fatal_error ("can't create directory %s: %m", r);
*s = sep;
/* Skip consecutive separators. */
temporary_file_name = concat (class_file_name, ".tmp", NULL);
stream = fopen (temporary_file_name, "wb");
if (stream == NULL)
- fatal_io_error ("can't open %s for writing", temporary_file_name);
+ fatal_error ("can't open %s for writing: %m", temporary_file_name);
jcf_dependency_add_target (class_file_name);
init_jcf_state (state, work);
chunks = generate_classfile (clas, state);
write_chunks (stream, chunks);
if (fclose (stream))
- fatal_io_error ("error closing %s", temporary_file_name);
+ fatal_error ("error closing %s: %m", temporary_file_name);
/* If a file named by the string pointed to by `new' exists
prior to the call to the `rename' function, the bahaviour
if (rename (temporary_file_name, class_file_name) == -1)
{
remove (temporary_file_name);
- fatal_io_error ("can't create %s", class_file_name);
+ fatal_error ("can't create %s: %m", class_file_name);
}
free (temporary_file_name);
free (class_file_name);
char *base;
if (!(fp = fopen (filename, "r")))
- fatal_io_error ("can't open %s", filename);
+ fatal_error ("can't open %s: %m", filename);
while (cline != line)
{
register char * const dumpname = concat (dump_base_name, ".decl", NULL);
gen_declaration_file = fopen (dumpname, "w");
if (gen_declaration_file == 0)
- fatal_io_error ("can't open %s", dumpname);
+ fatal_error ("can't open %s: %m", dumpname);
free (dumpname);
}
{
struct rlimit rlim;
if (getrlimit (RLIMIT_CORE, &rlim) != 0)
- fatal_io_error ("getting core file size maximum limit");
+ fatal_error ("getting core file size maximum limit: %m");
rlim.rlim_cur = rlim.rlim_max;
if (setrlimit (RLIMIT_CORE, &rlim) != 0)
- fatal_io_error ("setting core file size limit to maximum");
+ fatal_error ("setting core file size limit to maximum: %m");
}
#endif
diagnostic_abort_on_error (global_dc);
rtl_dump_file = fopen (dump_name, open_arg);
if (rtl_dump_file == NULL)
- fatal_io_error ("can't open %s", dump_name);
+ fatal_error ("can't open %s: %m", dump_name);
free (dump_name);
else
asm_out_file = fopen (asm_file_name, "w+");
if (asm_out_file == 0)
- fatal_io_error ("can't open %s for writing", asm_file_name);
+ fatal_error ("can't open %s for writing: %m", asm_file_name);
}
#ifdef IO_BUFFER_SIZE
{
aux_info_file = fopen (aux_info_file_name, "w");
if (aux_info_file == 0)
- fatal_io_error ("can't open %s", aux_info_file_name);
+ fatal_error ("can't open %s: %m", aux_info_file_name);
}
if (! targetm.have_named_sections)
if (asm_out_file)
{
if (ferror (asm_out_file) != 0)
- fatal_io_error ("error writing to %s", asm_file_name);
+ fatal_error ("error writing to %s: %m", asm_file_name);
if (fclose (asm_out_file) != 0)
- fatal_io_error ("error closing %s", asm_file_name);
+ fatal_error ("error closing %s: %m", asm_file_name);
}
/* Do whatever is necessary to finish printing the graphs. */
extern const char *trim_filename PARAMS ((const char *));
extern void internal_error PARAMS ((const char *, ...))
ATTRIBUTE_NORETURN;
-extern void fatal_io_error PARAMS ((const char *, ...))
- ATTRIBUTE_NORETURN;
extern void _fatal_insn_not_found PARAMS ((struct rtx_def *,
const char *, int,
const char *))