svn commit: r300500 - head/sys/compat/linuxkpi/common/include/linux

Hans Petter Selasky hselasky at FreeBSD.org
Mon May 23 12:35:08 UTC 2016


Author: hselasky
Date: Mon May 23 12:35:07 2016
New Revision: 300500
URL: https://svnweb.freebsd.org/changeset/base/300500

Log:
  Add more printf() related functions to the LinuxKPI.
  
  Obtained from:	kmacy @
  MFC after:	1 week
  Sponsored by:	Mellanox Technologies

Modified:
  head/sys/compat/linuxkpi/common/include/linux/kernel.h

Modified: head/sys/compat/linuxkpi/common/include/linux/kernel.h
==============================================================================
--- head/sys/compat/linuxkpi/common/include/linux/kernel.h	Mon May 23 12:13:16 2016	(r300499)
+++ head/sys/compat/linuxkpi/common/include/linux/kernel.h	Mon May 23 12:35:07 2016	(r300500)
@@ -52,6 +52,8 @@
 #include <linux/log2.h> 
 #include <asm/byteorder.h>
 
+#include <machine/stdarg.h>
+
 #define KERN_CONT       ""
 #define	KERN_EMERG	"<0>"
 #define	KERN_ALERT	"<1>"
@@ -124,7 +126,37 @@
 #define	DIV_ROUND_UP_ULL(x, n)	DIV_ROUND_UP((unsigned long long)(x), (n))
 #define	FIELD_SIZEOF(t, f)	sizeof(((t *)0)->f)
 
-#define	printk(X...)		printf(X)
+#define	printk(...)		printf(__VA_ARGS__)
+#define	vprintk(f, a)		vprintf(f, a)
+
+struct va_format {
+	const char *fmt;
+	va_list *va;
+};
+
+static inline int
+vscnprintf(char *buf, size_t size, const char *fmt, va_list args)
+{
+	ssize_t ssize = size;
+	int i;
+
+	i = vsnprintf(buf, size, fmt, args);
+
+	return ((i >= ssize) ? (ssize - 1) : i);
+}
+
+static inline int
+scnprintf(char *buf, size_t size, const char *fmt, ...)
+{
+	va_list args;
+	int i;
+
+	va_start(args, fmt);
+	i = vscnprintf(buf, size, fmt, args);
+	va_end(args);
+
+	return (i);
+}
 
 /*
  * The "pr_debug()" and "pr_devel()" macros should produce zero code


More information about the svn-src-all mailing list