Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 28 Nov 2022 17:27:10 GMT
From:      "Bjoern A. Zeeb" <bz@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 589a423b02ce - stable/13 - LinuxKPI: add memset_startat macro
Message-ID:  <202211281727.2ASHRA5K081381@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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_ */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202211281727.2ASHRA5K081381>