Wed Oct 14 15:52:41 2015 UTC ()
introduce a __syslog__ format, and __sysloglike() macros. If __syslog__
is not available, this fails back to __printf__


(christos)
diff -r1.126 -r1.127 src/sys/sys/cdefs.h
diff -r1.36 -r1.37 src/sys/sys/syslog.h

cvs diff -r1.126 -r1.127 src/sys/sys/cdefs.h (expand / switch to unified diff)

--- src/sys/sys/cdefs.h 2015/08/30 08:46:44 1.126
+++ src/sys/sys/cdefs.h 2015/10/14 15:52:40 1.127
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: cdefs.h,v 1.126 2015/08/30 08:46:44 mlelstv Exp $ */ 1/* $NetBSD: cdefs.h,v 1.127 2015/10/14 15:52:40 christos Exp $ */
2 2
3/* * Copyright (c) 1991, 1993 3/* * Copyright (c) 1991, 1993
4 * The Regents of the University of California. All rights reserved. 4 * The Regents of the University of California. All rights reserved.
5 * 5 *
6 * This code is derived from software contributed to Berkeley by 6 * This code is derived from software contributed to Berkeley by
7 * Berkeley Software Design, Inc. 7 * Berkeley Software Design, Inc.
8 * 8 *
9 * Redistribution and use in source and binary forms, with or without 9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions 10 * modification, are permitted provided that the following conditions
11 * are met: 11 * are met:
12 * 1. Redistributions of source code must retain the above copyright 12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer. 13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright 14 * 2. Redistributions in binary form must reproduce the above copyright
@@ -468,32 +468,38 @@ @@ -468,32 +468,38 @@
468#define __predict_true(exp) (exp) 468#define __predict_true(exp) (exp)
469#define __predict_false(exp) (exp) 469#define __predict_false(exp) (exp)
470#endif 470#endif
471 471
472/* 472/*
473 * Compiler-dependent macros to declare that functions take printf-like 473 * Compiler-dependent macros to declare that functions take printf-like
474 * or scanf-like arguments. They are null except for versions of gcc 474 * or scanf-like arguments. They are null except for versions of gcc
475 * that are known to support the features properly (old versions of gcc-2 475 * that are known to support the features properly (old versions of gcc-2
476 * didn't permit keeping the keywords out of the application namespace). 476 * didn't permit keeping the keywords out of the application namespace).
477 */ 477 */
478#if __GNUC_PREREQ__(2, 7) 478#if __GNUC_PREREQ__(2, 7)
479#define __printflike(fmtarg, firstvararg) \ 479#define __printflike(fmtarg, firstvararg) \
480 __attribute__((__format__ (__printf__, fmtarg, firstvararg))) 480 __attribute__((__format__ (__printf__, fmtarg, firstvararg)))
 481#ifndef __syslog_attribute__
 482#define __syslog__ __printf__
 483#endif
 484#define __sysloglike(fmtarg, firstvararg) \
 485 __attribute__((__format__ (__syslog__, fmtarg, firstvararg)))
481#define __scanflike(fmtarg, firstvararg) \ 486#define __scanflike(fmtarg, firstvararg) \
482 __attribute__((__format__ (__scanf__, fmtarg, firstvararg))) 487 __attribute__((__format__ (__scanf__, fmtarg, firstvararg)))
483#define __format_arg(fmtarg) __attribute__((__format_arg__ (fmtarg))) 488#define __format_arg(fmtarg) __attribute__((__format_arg__ (fmtarg)))
484#else 489#else
485#define __printflike(fmtarg, firstvararg) /* nothing */ 490#define __printflike(fmtarg, firstvararg) /* nothing */
486#define __scanflike(fmtarg, firstvararg) /* nothing */ 491#define __scanflike(fmtarg, firstvararg) /* nothing */
 492#define __sysloglike(fmtarg, firstvararg) /* nothing */
487#define __format_arg(fmtarg) /* nothing */ 493#define __format_arg(fmtarg) /* nothing */
488#endif 494#endif
489 495
490/* 496/*
491 * Macros for manipulating "link sets". Link sets are arrays of pointers 497 * Macros for manipulating "link sets". Link sets are arrays of pointers
492 * to objects, which are gathered up by the linker. 498 * to objects, which are gathered up by the linker.
493 * 499 *
494 * Object format-specific code has provided us with the following macros: 500 * Object format-specific code has provided us with the following macros:
495 * 501 *
496 * __link_set_add_text(set, sym) 502 * __link_set_add_text(set, sym)
497 * Add a reference to the .text symbol `sym' to `set'. 503 * Add a reference to the .text symbol `sym' to `set'.
498 * 504 *
499 * __link_set_add_rodata(set, sym) 505 * __link_set_add_rodata(set, sym)

cvs diff -r1.36 -r1.37 src/sys/sys/syslog.h (expand / switch to unified diff)

--- src/sys/sys/syslog.h 2014/07/20 20:55:17 1.36
+++ src/sys/sys/syslog.h 2015/10/14 15:52:40 1.37
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: syslog.h,v 1.36 2014/07/20 20:55:17 dholland Exp $ */ 1/* $NetBSD: syslog.h,v 1.37 2015/10/14 15:52:40 christos Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1982, 1986, 1988, 1993 4 * Copyright (c) 1982, 1986, 1988, 1993
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -191,47 +191,47 @@ struct syslog_data { @@ -191,47 +191,47 @@ struct syslog_data {
191 .log_hostname = { '\0' }, \ 191 .log_hostname = { '\0' }, \
192 .log_fac = LOG_USER, \ 192 .log_fac = LOG_USER, \
193 .log_mask = 0xff, \ 193 .log_mask = 0xff, \
194} 194}
195 195
196#include <sys/cdefs.h> 196#include <sys/cdefs.h>
197#include <sys/featuretest.h> 197#include <sys/featuretest.h>
198#include <sys/ansi.h> 198#include <sys/ansi.h>
199 199
200__BEGIN_DECLS 200__BEGIN_DECLS
201void closelog(void); 201void closelog(void);
202void openlog(const char *, int, int); 202void openlog(const char *, int, int);
203int setlogmask(int); 203int setlogmask(int);
204void syslog(int, const char *, ...) __printflike(2, 3); 204void syslog(int, const char *, ...) __sysloglike(2, 3);
205#if defined(_NETBSD_SOURCE) 205#if defined(_NETBSD_SOURCE)
206void vsyslog(int, const char *, __va_list) __printflike(2, 0); 206void vsyslog(int, const char *, __va_list) __sysloglike(2, 0);
207#ifndef __LIBC12_SOURCE__ 207#ifndef __LIBC12_SOURCE__
208void closelog_r(struct syslog_data *) __RENAME(__closelog_r60); 208void closelog_r(struct syslog_data *) __RENAME(__closelog_r60);
209void openlog_r(const char *, int, int, struct syslog_data *) 209void openlog_r(const char *, int, int, struct syslog_data *)
210 __RENAME(__openlog_r60); 210 __RENAME(__openlog_r60);
211int setlogmask_r(int, struct syslog_data *) __RENAME(__setlogmask_r60); 211int setlogmask_r(int, struct syslog_data *) __RENAME(__setlogmask_r60);
212void syslog_r(int, struct syslog_data *, const char *, ...) 212void syslog_r(int, struct syslog_data *, const char *, ...)
213 __RENAME(__syslog_r60) __printflike(3, 4); 213 __RENAME(__syslog_r60) __sysloglike(3, 4);
214void vsyslog_r(int, struct syslog_data *, const char *, __va_list) 214void vsyslog_r(int, struct syslog_data *, const char *, __va_list)
215 __RENAME(__vsyslog_r60) __printflike(3, 0); 215 __RENAME(__vsyslog_r60) __sysloglike(3, 0);
216void syslogp_r(int, struct syslog_data *, const char *, const char *, 216void syslogp_r(int, struct syslog_data *, const char *, const char *,
217 const char *, ...) __RENAME(__syslogp_r60) __printflike(5, 6); 217 const char *, ...) __RENAME(__syslogp_r60) __sysloglike(5, 6);
218void vsyslogp_r(int, struct syslog_data *, const char *, const char *, 218void vsyslogp_r(int, struct syslog_data *, const char *, const char *,
219 const char *, __va_list) __RENAME(__vsyslogp_r60) __printflike(5, 0); 219 const char *, __va_list) __RENAME(__vsyslogp_r60) __sysloglike(5, 0);
220#endif 220#endif
221void syslogp(int, const char *, const char *, const char *, ...) 221void syslogp(int, const char *, const char *, const char *, ...)
222 __printflike(4, 5); 222 __sysloglike(4, 5);
223void vsyslogp(int, const char *, const char *, const char *, __va_list) 223void vsyslogp(int, const char *, const char *, const char *, __va_list)
224 __printflike(4, 0); 224 __sysloglike(4, 0);
225#endif 225#endif
226__END_DECLS 226__END_DECLS
227 227
228#else /* !_KERNEL */ 228#else /* !_KERNEL */
229 229
230void logpri(int); 230void logpri(int);
231void log(int, const char *, ...) __printflike(2, 3); 231void log(int, const char *, ...) __printflike(2, 3);
232void vlog(int, const char *, __va_list) __printflike(2, 0); 232void vlog(int, const char *, __va_list) __printflike(2, 0);
233void addlog(const char *, ...) __printflike(1, 2); 233void addlog(const char *, ...) __printflike(1, 2);
234void logwakeup(void); 234void logwakeup(void);
235 235
236#endif /* !_KERNEL */ 236#endif /* !_KERNEL */
237 237