git: 362136ed4987 - main - linuxkpi: Add `strtomem()` and `strtomem_pad()`
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 06 Apr 2026 19:55:24 UTC
The branch main has been updated by dumbbell:
URL: https://cgit.FreeBSD.org/src/commit/?id=362136ed4987230269740f54531f6a945f00d135
commit 362136ed4987230269740f54531f6a945f00d135
Author: Jean-Sébastien Pédron <dumbbell@FreeBSD.org>
AuthorDate: 2026-03-02 23:04:09 +0000
Commit: Jean-Sébastien Pédron <dumbbell@FreeBSD.org>
CommitDate: 2026-04-06 19:28:08 +0000
linuxkpi: Add `strtomem()` and `strtomem_pad()`
The DRM generic code started to use `strtomem_pad()` in Linux 6.11.
Reviewed by: bz
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D55729
---
sys/compat/linuxkpi/common/include/linux/string.h | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/sys/compat/linuxkpi/common/include/linux/string.h b/sys/compat/linuxkpi/common/include/linux/string.h
index f7b64560d254..0b858e7af623 100644
--- a/sys/compat/linuxkpi/common/include/linux/string.h
+++ b/sys/compat/linuxkpi/common/include/linux/string.h
@@ -303,6 +303,22 @@ memcpy_and_pad(void *dst, size_t dstlen, const void *src, size_t len, int ch)
}
}
+#define strtomem(dst, src) do { \
+ size_t dstlen = ARRAY_SIZE(dst); \
+ size_t srclen = __builtin_object_size(src, 1); \
+ srclen = MIN(srclen, dstlen); \
+ srclen = strnlen(src, srclen); \
+ memcpy(dst, src, srclen); \
+} while (0)
+
+#define strtomem_pad(dst, src, pad) do { \
+ size_t dstlen = ARRAY_SIZE(dst); \
+ size_t srclen = __builtin_object_size(src, 1); \
+ srclen = MIN(srclen, dstlen); \
+ srclen = strnlen(src, srclen); \
+ memcpy_and_pad(dst, dstlen, src, srclen, pad); \
+} while (0)
+
#define memset_startat(ptr, bytepat, smember) \
({ \
uint8_t *_ptr = (uint8_t *)(ptr); \