mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-19 21:00:29 +07:00
c5af58b769
This patch adds string optimize codes and some auxiliary codes. Signed-off-by: Chen Linfei <linfei_chen@c-sky.com> Signed-off-by: Mao Han <han_mao@c-sky.com> Signed-off-by: Guo Ren <ren_guo@c-sky.com> Reviewed-by: Arnd Bergmann <arnd@arndb.de>
38 lines
571 B
C
38 lines
571 B
C
// SPDX-License-Identifier: GPL-2.0
|
|
// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
|
|
|
|
#include <linux/types.h>
|
|
|
|
void *memset(void *dest, int c, size_t l)
|
|
{
|
|
char *d = dest;
|
|
int ch = c & 0xff;
|
|
int tmp = (ch | ch << 8 | ch << 16 | ch << 24);
|
|
|
|
while (((uintptr_t)d & 0x3) && l--)
|
|
*d++ = ch;
|
|
|
|
while (l >= 16) {
|
|
*(((u32 *)d)) = tmp;
|
|
*(((u32 *)d)+1) = tmp;
|
|
*(((u32 *)d)+2) = tmp;
|
|
*(((u32 *)d)+3) = tmp;
|
|
l -= 16;
|
|
d += 16;
|
|
}
|
|
|
|
while (l > 3) {
|
|
*(((u32 *)d)) = tmp;
|
|
l -= 4;
|
|
d += 4;
|
|
}
|
|
|
|
while (l) {
|
|
*d = ch;
|
|
l--;
|
|
d++;
|
|
}
|
|
|
|
return dest;
|
|
}
|