Commit 10fbfd1b by Georg-Johann Lay Committed by Georg-Johann Lay

Use variadic macros with avr-log.c.

	* config/avr/avr-protos.h (avr_vdump): New prototype.
	(avr_log_set_caller_e, avr_log_set_caller_f): Remove protos.
	(avr_edump, avr_fdump, avr_dump): (Re)define to use avr_vdump.
	* config/avr/avr-log.c: Adjust comments.
	(avr_vdump): New function.
	(avr_vadump): Pass caller as 2nd argument instead of format string.
	(avr_log_caller, avr_log_fdump_e, avr_log_fdump_f)
	(avr_log_set_caller_e, avr_log_set_caller_f): Remove.

From-SVN: r220962
parent 1d3d9afa
2015-02-25 Georg-Johann Lay <avr@gjlay.de>
Use variadic macros with avr-log.c.
* config/avr/avr-protos.h (avr_vdump): New prototype.
(avr_log_set_caller_e, avr_log_set_caller_f): Remove protos.
(avr_edump, avr_fdump, avr_dump): (Re)define to use avr_vdump.
* config/avr/avr-log.c: Adjust comments.
(avr_vdump): New function.
(avr_vadump): Pass caller as 2nd argument instead of format string.
(avr_log_caller, avr_log_fdump_e, avr_log_fdump_f)
(avr_log_set_caller_e, avr_log_set_caller_f): Remove.
2015-02-25 Jakub Jelinek <jakub@redhat.com> 2015-02-25 Jakub Jelinek <jakub@redhat.com>
PR lto/64374 PR lto/64374
...@@ -16,7 +29,7 @@ ...@@ -16,7 +29,7 @@
* config/xtensa/xtensa.md (zero_cost_loop_start): Reverse numbering * config/xtensa/xtensa.md (zero_cost_loop_start): Reverse numbering
of operand 0 and operand 2. of operand 0 and operand 2.
(zero_cost_loop_end, loop_end): Similarly. (zero_cost_loop_end, loop_end): Similarly.
2015-02-24 Aldy Hernandez <aldyh@redhat.com> 2015-02-24 Aldy Hernandez <aldyh@redhat.com>
* gimple.h (gimple_build_assign): Rename CXX_MEM_STAT_DECL to * gimple.h (gimple_build_assign): Rename CXX_MEM_STAT_DECL to
......
...@@ -43,13 +43,11 @@ ...@@ -43,13 +43,11 @@
/* This file supplies some functions for AVR back-end developers /* This file supplies some functions for AVR back-end developers
with a printf-like interface. The functions are called through with a printf-like interface. The functions are called through
macros avr_edump or avr_fdump from avr-protos.h: macros `avr_dump', `avr_edump' or `avr_fdump' from avr-protos.h:
avr_edump (const char *fmt, ...);
avr_fdump (FILE *stream, const char *fmt, ...);
avr_fdump (FILE *stream, const char *fmt, ...);
avr_edump (fmt, ...) is a shortcut for avr_fdump (stderr, fmt, ...) avr_edump (fmt, ...) is a shortcut for avr_fdump (stderr, fmt, ...)
avr_dump (fmt, ...) is a shortcut for avr_fdump (dump_file, fmt, ...)
== known %-codes == == known %-codes ==
...@@ -85,76 +83,41 @@ ...@@ -85,76 +83,41 @@
/* Set according to -mlog= option. */ /* Set according to -mlog= option. */
avr_log_t avr_log; avr_log_t avr_log;
/* The caller as of __FUNCTION__ */
static const char *avr_log_caller = "?";
/* The worker function implementing the %-codes */ /* The worker function implementing the %-codes */
static void avr_log_vadump (FILE*, const char*, va_list); static void avr_log_vadump (FILE*, const char*, va_list);
/* As we have no variadic macros, avr_edump maps to a call to /* Wrapper for avr_log_vadump. If STREAM is NULL we are called by avr_dump,
avr_log_set_caller_e which saves __FUNCTION__ to avr_log_caller and i.e. output to dump_file if available. The 2nd argument is __FUNCTION__.
returns a function pointer to avr_log_fdump_e. avr_log_fdump_e The 3rd argument is the format string. */
gets the printf-like arguments and calls avr_log_vadump, the
worker function. avr_fdump works the same way. */
/* Provide avr_log_fdump_e/f so that avr_log_set_caller_e/_f can return
their address. */
static int
avr_log_fdump_e (const char *fmt, ...)
{
va_list ap;
va_start (ap, fmt);
avr_log_vadump (stderr, fmt, ap);
va_end (ap);
return 1;
}
static int int
avr_log_fdump_f (FILE *stream, const char *fmt, ...) avr_vdump (FILE *stream, const char *caller, ...)
{ {
va_list ap; va_list ap;
if (NULL == stream && dump_file)
stream = dump_file;
va_start (ap, fmt); va_start (ap, caller);
if (stream) if (stream)
avr_log_vadump (stream, fmt, ap); avr_log_vadump (stream, caller, ap);
va_end (ap); va_end (ap);
return 1; return 1;
} }
/* Macros avr_edump/avr_fdump map to calls of the following two functions,
respectively. You don't need to call them directly. */
int (*
avr_log_set_caller_e (const char *caller)
)(const char*, ...)
{
avr_log_caller = caller;
return avr_log_fdump_e;
}
int (*
avr_log_set_caller_f (const char *caller)
)(FILE*, const char*, ...)
{
avr_log_caller = caller;
return avr_log_fdump_f;
}
/* Worker function implementing the %-codes and forwarding to /* Worker function implementing the %-codes and forwarding to
respective print/dump function. */ respective print/dump function. */
static void static void
avr_log_vadump (FILE *file, const char *fmt, va_list ap) avr_log_vadump (FILE *file, const char *caller, va_list ap)
{ {
char bs[3] = {'\\', '?', '\0'}; char bs[3] = {'\\', '?', '\0'};
/* 3rd proper argument is always the format string. */
const char *fmt = va_arg (ap, const char*);
while (*fmt) while (*fmt)
{ {
switch (*fmt++) switch (*fmt++)
...@@ -256,7 +219,7 @@ avr_log_vadump (FILE *file, const char *fmt, va_list ap) ...@@ -256,7 +219,7 @@ avr_log_vadump (FILE *file, const char *fmt, va_list ap)
break; break;
case 'F': case 'F':
fputs (avr_log_caller, file); fputs (caller, file);
break; break;
case 'H': case 'H':
...@@ -280,7 +243,7 @@ avr_log_vadump (FILE *file, const char *fmt, va_list ap) ...@@ -280,7 +243,7 @@ avr_log_vadump (FILE *file, const char *fmt, va_list ap)
/* FALLTHRU */ /* FALLTHRU */
case '?': case '?':
avr_log_fdump_f (file, "%F[%f:%P]"); avr_vdump (file, caller, "%F[%f:%P]");
break; break;
case 'P': case 'P':
......
...@@ -155,12 +155,11 @@ extern bool avr_have_dimode; ...@@ -155,12 +155,11 @@ extern bool avr_have_dimode;
/* From avr-log.c */ /* From avr-log.c */
#define avr_edump (avr_log_set_caller_e (__FUNCTION__)) #define avr_dump(...) avr_vdump (NULL, __FUNCTION__, __VA_ARGS__)
#define avr_fdump (avr_log_set_caller_f (__FUNCTION__)) #define avr_edump(...) avr_vdump (stderr, __FUNCTION__, __VA_ARGS__)
#define avr_fdump(FIL, ...) avr_vdump (FIL, __FUNCTION__, __VA_ARGS__)
extern int (*avr_log_set_caller_e (const char*))(const char*, ...);
extern int (*avr_log_set_caller_f (const char*))(FILE*, const char*, ...);
extern int avr_vdump (FILE*, const char*, ...);
extern void avr_log_set_avr_log (void); extern void avr_log_set_avr_log (void);
typedef struct typedef struct
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment