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
This commit is contained in:
Emmanuel Vadot 2022-07-26 11:28:11 +02:00
parent 96b917bfcf
commit fa1f02baaf

View File

@ -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_ */