Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/external/bsd/common/include/linux Implement Linux kaspri...
details: https://anonhg.NetBSD.org/src/rev/332f7de72099
branches: trunk
changeset: 365795:332f7de72099
user: riastradh <riastradh%NetBSD.org@localhost>
date: Mon Aug 27 06:46:55 2018 +0000
description:
Implement Linux kasprintf.
diffstat:
sys/external/bsd/common/include/linux/kernel.h | 27 +++++++++++++++++++++++++-
1 files changed, 26 insertions(+), 1 deletions(-)
diffs (46 lines):
diff -r 22dfe613ab55 -r 332f7de72099 sys/external/bsd/common/include/linux/kernel.h
--- a/sys/external/bsd/common/include/linux/kernel.h Mon Aug 27 06:46:32 2018 +0000
+++ b/sys/external/bsd/common/include/linux/kernel.h Mon Aug 27 06:46:55 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kernel.h,v 1.13 2018/08/27 06:15:32 riastradh Exp $ */
+/* $NetBSD: kernel.h,v 1.14 2018/08/27 06:46:55 riastradh Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -40,6 +40,7 @@
#include <lib/libkern/libkern.h>
#include <linux/bitops.h>
#include <linux/printk.h>
+#include <linux/slab.h>
#define U16_MAX UINT16_MAX
#define U32_MAX UINT32_MAX
@@ -179,4 +180,28 @@
return 0;
}
+static inline char * __printflike(2,3)
+kasprintf(gfp_t gfp, const char *fmt, ...)
+{
+ va_list va;
+ char *str;
+ int len, len1 __diagused;
+
+ va_start(va, fmt);
+ len = vsnprintf(NULL, 0, fmt, va);
+ va_end(va);
+
+ str = kmalloc(len + 1, gfp);
+ if (str == NULL)
+ return NULL;
+
+ va_start(va, fmt);
+ len1 = vsnprintf(str, len + 1, fmt, va);
+ va_end(va);
+
+ KASSERT(len1 == len);
+
+ return str;
+}
+
#endif /* _LINUX_KERNEL_H_ */
Home |
Main Index |
Thread Index |
Old Index