Skip to content

Commit 4370aa4

Browse files
Lai JiangshanIngo Molnar
authored andcommitted
vsprintf: add binary printf
Impact: add new APIs for binary trace printk infrastructure vbin_printf(): write args to binary buffer, string is copied when "%s" is occurred. bstr_printf(): read from binary buffer for args and format a string [[email protected]: rebase] Signed-off-by: Lai Jiangshan <[email protected]> Signed-off-by: Frederic Weisbecker <[email protected]> Cc: Linus Torvalds <[email protected]> LKML-Reference: <[email protected]> Signed-off-by: Ingo Molnar <[email protected]>
1 parent f036be9 commit 4370aa4

File tree

3 files changed

+452
-0
lines changed

3 files changed

+452
-0
lines changed

include/linux/string.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <linux/compiler.h> /* for inline */
1111
#include <linux/types.h> /* for size_t */
1212
#include <linux/stddef.h> /* for NULL */
13+
#include <stdarg.h>
1314

1415
extern char *strndup_user(const char __user *, long);
1516

@@ -111,6 +112,12 @@ extern void argv_free(char **argv);
111112

112113
extern bool sysfs_streq(const char *s1, const char *s2);
113114

115+
#ifdef CONFIG_BINARY_PRINTF
116+
int vbin_printf(u32 *bin_buf, size_t size, const char *fmt, va_list args);
117+
int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf);
118+
int bprintf(u32 *bin_buf, size_t size, const char *fmt, ...) __printf(3, 4);
119+
#endif
120+
114121
extern ssize_t memory_read_from_buffer(void *to, size_t count, loff_t *ppos,
115122
const void *from, size_t available);
116123

lib/Kconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
# Library configuration
33
#
44

5+
config BINARY_PRINTF
6+
def_bool n
7+
58
menu "Library routines"
69

710
config BITREVERSE

0 commit comments

Comments
 (0)