Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 23 May 2016 12:35:07 +0000 (UTC)
From:      Hans Petter Selasky <hselasky@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r300500 - head/sys/compat/linuxkpi/common/include/linux
Message-ID:  <201605231235.u4NCZ7s9020533@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201605231235.u4NCZ7s9020533>