Re: [HACKERS] TPRINTF in trace.h

From: Massimo Dal Zotto <dz(at)cs(dot)unitn(dot)it>
To: hacker(at)cs(dot)unitn(dot)it, pgsql-patches(at)postgreSQL(dot)org (Pgsql Patches)
Cc: maillist(at)candle(dot)pha(dot)pa(dot)us (Bruce Momjian), andreas(dot)zeugswetter(at)telecom(dot)at
Subject: Re: [HACKERS] TPRINTF in trace.h
Date: 1998-08-31 20:51:21
Message-ID: 199808312052.WAA09451@nikita.wizard.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

>
> > The recent changes in the tracing code are unfortunately not portable.
> >
> > #define PRINTF(args...) tprintf(TRACE_ALL, args)
> >
> > is not accepted by all compilers. Is there another way to express this ?
> > Is my AIX xlc Version 3.1.4 the only one with this problem ?
>
> Yikes, that is certainly not standard C. I have never seen that before.
> Looks like a GNU-ism. I nice one, but still a GNU-ism.

Sorry, I didn't know it is a GNU extension. I have written this patch
which should fix the problem. Let me know if you still have problems.

*** src/include/utils/trace.h.orig Tue Aug 25 23:43:47 1998
--- src/include/utils/trace.h Mon Aug 31 22:35:47 1998
***************
*** 26,31 ****
--- 26,32 ----
#define TIMESTAMP_SIZE 0
#endif

+ extern int tprintf1(const char *fmt, ...);
extern int tprintf(int flag, const char *fmt, ...);
extern int eprintf(const char *fmt, ...);
extern int option_flag(int flag);
***************
*** 70,78 ****

extern int pg_options[NUM_PG_OPTIONS];

! #define PRINTF(args...) tprintf(TRACE_ALL, args)
#define EPRINTF(args...) eprintf(args)
#define TPRINTF(flag, args...) tprintf(flag, args)

#endif /* TRACE_H */

--- 71,85 ----

extern int pg_options[NUM_PG_OPTIONS];

! #ifdef __GNUC__
! #define PRINTF(args...) tprintf1(args)
#define EPRINTF(args...) eprintf(args)
#define TPRINTF(flag, args...) tprintf(flag, args)
+ #else
+ #define PRINTF tprintf1
+ #define EPRINTF eprintf
+ #define TPRINTF tprintf
+ #endif

#endif /* TRACE_H */

*** src/backend/utils/misc/trace.c.orig Tue Aug 25 23:43:47 1998
--- src/backend/utils/misc/trace.c Mon Aug 31 22:36:10 1998
***************
*** 126,131 ****
--- 126,159 ----
}

/*
+ * Print a timestamp and a message to stdout or to syslog.
+ */
+ int
+ tprintf1(const char *fmt, ... )
+ {
+ va_list ap;
+ char line[ELOG_MAXLEN+TIMESTAMP_SIZE+1];
+
+ va_start(ap, fmt);
+ #ifdef ELOG_TIMESTAMPS
+ strcpy(line, tprintf_timestamp());
+ #endif
+ vsprintf(line+TIMESTAMP_SIZE, fmt, ap);
+ va_end(ap);
+
+ #ifdef USE_SYSLOG
+ write_syslog(LOG_INFO, line+TIMESTAMP_SIZE);
+ #endif
+
+ if (UseSyslog <= 1) {
+ puts(line);
+ fflush(stdout);
+ }
+
+ return 1;
+ }
+
+ /*
* Print a timestamp and a message to stderr.
*/
int

--
Massimo Dal Zotto

+----------------------------------------------------------------------+
| Massimo Dal Zotto email: dz(at)cs(dot)unitn(dot)it |
| Via Marconi, 141 phone: ++39-461-534251 |
| 38057 Pergine Valsugana (TN) www: http://www.cs.unitn.it/~dz/ |
| Italy pgp: finger dz(at)tango(dot)cs(dot)unitn(dot)it |
+----------------------------------------------------------------------+

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Massimo Dal Zotto 1998-08-31 21:02:51 Re: [HACKERS] flock patch breaks things here
Previous Message Keith Parks 1998-08-31 19:19:29 Re: [HACKERS] Core dump in regression tests.