diff options
author | hselasky <hselasky@FreeBSD.org> | 2016-05-23 12:35:07 +0000 |
---|---|---|
committer | hselasky <hselasky@FreeBSD.org> | 2016-05-23 12:35:07 +0000 |
commit | bbffa168e81624058a78677ff76128ff19aaf3ff (patch) | |
tree | ad182297860e7c26ce62a9f0190ca013c5045936 | |
parent | 8f6176cfd2a6d7a3148059cb9323cfe18d5a029e (diff) | |
download | FreeBSD-src-bbffa168e81624058a78677ff76128ff19aaf3ff.zip FreeBSD-src-bbffa168e81624058a78677ff76128ff19aaf3ff.tar.gz |
Add more printf() related functions to the LinuxKPI.
Obtained from: kmacy @
MFC after: 1 week
Sponsored by: Mellanox Technologies
-rw-r--r-- | sys/compat/linuxkpi/common/include/linux/kernel.h | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/sys/compat/linuxkpi/common/include/linux/kernel.h b/sys/compat/linuxkpi/common/include/linux/kernel.h index 9f280ce..b813bd4 100644 --- a/sys/compat/linuxkpi/common/include/linux/kernel.h +++ b/sys/compat/linuxkpi/common/include/linux/kernel.h @@ -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 |