mirror of
https://github.com/opnsense/src.git
synced 2026-05-28 04:12:45 -04:00
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:
parent
96b917bfcf
commit
fa1f02baaf
1 changed files with 32 additions and 1 deletions
|
|
@ -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_ */
|
||||
|
|
|
|||
Loading…
Reference in a new issue