summaryrefslogtreecommitdiffstats
path: root/lib/log.h
diff options
context:
space:
mode:
authorRick Balocca <rbalocca@vyatta.com>2008-10-16 17:39:55 -0700
committerRick Balocca <rbalocca@vyatta.com>2008-10-16 17:39:55 -0700
commit04c7298b3684ddda4e6669f14374e2377deb04ea (patch)
treeb3c11943294ffc282863dbca418d408a7869f86f /lib/log.h
parent1581cf27e9e187a12f25221cc42123a056469adb (diff)
parentfa3e86a1a7559808ba5e32374e35d387472567c8 (diff)
downloadquagga-04c7298b3684ddda4e6669f14374e2377deb04ea.tar.bz2
quagga-04c7298b3684ddda4e6669f14374e2377deb04ea.tar.xz
Merge branch 'islavista'
Conflicts: debian/changelog
Diffstat (limited to 'lib/log.h')
-rw-r--r--lib/log.h47
1 files changed, 34 insertions, 13 deletions
diff --git a/lib/log.h b/lib/log.h
index 691368c0..5411fa6b 100644
--- a/lib/log.h
+++ b/lib/log.h
@@ -105,27 +105,48 @@ extern void closezlog (struct zlog *zl);
/* GCC have printf type attribute check. */
#ifdef __GNUC__
-#define PRINTF_ATTRIBUTE(a,b) __attribute__ ((__format__ (__printf__, a, b)))
+#define PRINTF_ATTRIBUTE(a,b) __attribute__ ((format (printf, a, b)))
#else
#define PRINTF_ATTRIBUTE(a,b)
#endif /* __GNUC__ */
+#if !(__GNUC__ == 4)
+/* Mark functions as cold. gcc will assume any path leading to a call
+ to them will be unlikely. This means a lot of paths leading up
+ to log messages are easily marked as not likely.
+*/
+#define COLD_ATTRIBUTE __attribute__((__cold__))
+#else
+#define COLD_ATTRIBUTE
+#endif
+
/* Generic function for zlog. */
-extern void zlog (struct zlog *zl, int priority, const char *format, ...) PRINTF_ATTRIBUTE(3, 4);
+extern void zlog (struct zlog *zl, int priority, const char *format, ...)
+ PRINTF_ATTRIBUTE(3, 4);
/* Handy zlog functions. */
-extern void zlog_err (const char *format, ...) PRINTF_ATTRIBUTE(1, 2);
-extern void zlog_warn (const char *format, ...) PRINTF_ATTRIBUTE(1, 2);
-extern void zlog_info (const char *format, ...) PRINTF_ATTRIBUTE(1, 2);
-extern void zlog_notice (const char *format, ...) PRINTF_ATTRIBUTE(1, 2);
-extern void zlog_debug (const char *format, ...) PRINTF_ATTRIBUTE(1, 2);
+extern void zlog_err (const char *format, ...)
+ PRINTF_ATTRIBUTE(1, 2) COLD_ATTRIBUTE;
+extern void zlog_warn (const char *format, ...)
+ PRINTF_ATTRIBUTE(1, 2) COLD_ATTRIBUTE;
+extern void zlog_info (const char *format, ...)
+ PRINTF_ATTRIBUTE(1, 2) COLD_ATTRIBUTE;
+extern void zlog_notice (const char *format, ...)
+ PRINTF_ATTRIBUTE(1, 2) COLD_ATTRIBUTE;
+extern void zlog_debug (const char *format, ...)
+ PRINTF_ATTRIBUTE(1, 2) COLD_ATTRIBUTE;
/* For bgpd's peer oriented log. */
-extern void plog_err (struct zlog *, const char *format, ...);
-extern void plog_warn (struct zlog *, const char *format, ...);
-extern void plog_info (struct zlog *, const char *format, ...);
-extern void plog_notice (struct zlog *, const char *format, ...);
-extern void plog_debug (struct zlog *, const char *format, ...);
+extern void plog_err (struct zlog *, const char *format, ...)
+ PRINTF_ATTRIBUTE(2, 3) COLD_ATTRIBUTE;
+extern void plog_warn (struct zlog *, const char *format, ...)
+ PRINTF_ATTRIBUTE(2, 3) COLD_ATTRIBUTE;
+extern void plog_info (struct zlog *, const char *format, ...)
+ PRINTF_ATTRIBUTE(2, 3) COLD_ATTRIBUTE;
+extern void plog_notice (struct zlog *, const char *format, ...)
+ PRINTF_ATTRIBUTE(2, 3) COLD_ATTRIBUTE;
+extern void plog_debug (struct zlog *, const char *format, ...)
+ PRINTF_ATTRIBUTE(2, 3) COLD_ATTRIBUTE;
/* Set logging level for the given destination. If the log_level
argument is ZLOG_DISABLED, then the destination is disabled.
@@ -144,7 +165,7 @@ extern int zlog_rotate (struct zlog *);
/* For hackey massage lookup and check */
#define LOOKUP(x, y) mes_lookup(x, x ## _max, y, "(no item found)")
-extern const char *lookup (struct message *, int);
+extern const char *lookup (const struct message *, int);
extern const char *mes_lookup (struct message *meslist,
int max, int index,
const char *no_item);