git: fa1f02baafd3 - main - linuxkpi: Add some memset functions
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 08 Aug 2022 14:04:18 UTC
The branch main has been updated by manu:
URL: https://cgit.FreeBSD.org/src/commit/?id=fa1f02baafd3d46e9d09a3715be23e96b601d9c9
commit fa1f02baafd3d46e9d09a3715be23e96b601d9c9
Author: Emmanuel Vadot <manu@FreeBSD.org>
AuthorDate: 2022-07-26 09:28:11 +0000
Commit: Emmanuel Vadot <manu@FreeBSD.org>
CommitDate: 2022-08-08 13:22:35 +0000
linuxkpi: Add some memset functions
Needed by drm-kmod
Obtained from: OpenBSD
Sponsored by: Beckhoff Automation GmbH & Co. KG
Differential Revision: https://reviews.freebsd.org/D35943
---
sys/compat/linuxkpi/common/include/linux/string.h | 33 ++++++++++++++++++++++-
1 file changed, 32 insertions(+), 1 deletion(-)
diff --git a/sys/compat/linuxkpi/common/include/linux/string.h b/sys/compat/linuxkpi/common/include/linux/string.h
index 73a38dc42c6c..7a118bb17c48 100644
--- a/sys/compat/linuxkpi/common/include/linux/string.h
+++ b/sys/compat/linuxkpi/common/include/linux/string.h
@@ -38,6 +38,7 @@
#include <linux/slab.h>
#include <linux/uaccess.h>
#include <linux/err.h>
+#include <linux/bitops.h> /* for BITS_PER_LONG */
#include <sys/libkern.h>
@@ -196,4 +197,34 @@ strscpy(char* dst, const char* src, size_t len)
return (-E2BIG);
}
-#endif /* _LINUXKPI_LINUX_STRING_H_ */
+static inline void *
+memset32(uint32_t *b, uint32_t c, size_t len)
+{
+ uint32_t *dst = b;
+
+ while (len--)
+ *dst++ = c;
+ return (b);
+}
+
+static inline void *
+memset64(uint64_t *b, uint64_t c, size_t len)
+{
+ uint64_t *dst = b;
+
+ while (len--)
+ *dst++ = c;
+ return (b);
+}
+
+static inline void *
+memset_p(void **p, void *v, size_t n)
+{
+
+ if (BITS_PER_LONG == 32)
+ return (memset32((uint32_t *)p, (uintptr_t)v, n));
+ else
+ return (memset64((uint64_t *)p, (uintptr_t)v, n));
+}
+
+#endif /* _LINUXKPI_LINUX_STRING_H_ */