git: 589a423b02ce - stable/13 - LinuxKPI: add memset_startat macro
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 28 Nov 2022 17:27:10 UTC
The branch stable/13 has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=589a423b02ce15a415312eda1ba7ab2b5533162d commit 589a423b02ce15a415312eda1ba7ab2b5533162d Author: Bjoern A. Zeeb <bz@FreeBSD.org> AuthorDate: 2022-11-14 23:26:22 +0000 Commit: Bjoern A. Zeeb <bz@FreeBSD.org> CommitDate: 2022-11-28 16:34:42 +0000 LinuxKPI: add memset_startat macro Add a memset_startat() macro which sets a pattern from a struct member to the end of the struct. Needed by a wireless driver. Reviewed by: emaste Differential Revision: https://reviews.freebsd.org/D37389 (cherry picked from commit 5d310ea8c5f98bbf53078ec632f6441f54dc9e44) --- sys/compat/linuxkpi/common/include/linux/string.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sys/compat/linuxkpi/common/include/linux/string.h b/sys/compat/linuxkpi/common/include/linux/string.h index c721ea6bab9d..95a9d5a76594 100644 --- a/sys/compat/linuxkpi/common/include/linux/string.h +++ b/sys/compat/linuxkpi/common/include/linux/string.h @@ -240,4 +240,12 @@ memcpy_and_pad(void *dst, size_t dstlen, const void *src, size_t len, int ch) } } +#define memset_startat(ptr, bytepat, smember) \ +({ \ + uint8_t *_ptr = (uint8_t *)(ptr); \ + int _c = (int)(bytepat); \ + size_t _o = offsetof(typeof(*(ptr)), smember); \ + memset(_ptr + _o, _c, sizeof(*(ptr)) - _o); \ +}) + #endif /* _LINUXKPI_LINUX_STRING_H_ */