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. MFC after: 3 days Reviewed by: emaste Differential Revision: https://reviews.freebsd.org/D37389
This commit is contained in:
parent
386a5e3ae6
commit
5d310ea8c5
@ -249,4 +249,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_ */
|
#endif /* _LINUXKPI_LINUX_STRING_H_ */
|
||||||
|
Loading…
Reference in New Issue
Block a user