1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 #include <linux/types.h>
3 #include <asm/string.h>
5 #define OPSIZ (BITS_PER_LONG/8)
6 typedef unsigned long op_t;
9 memset (void *dstpp, int sc, size_t len)
12 long int dstp = (long int) dstpp;
19 cccc = (unsigned char) c;
23 /* Do the shift in two steps to avoid warning if long has 32 bits. */
24 cccc |= (cccc << 16) << 16;
26 /* There are at least some bytes to set.
27 No need to test for LEN == 0 in this alignment loop. */
28 while (dstp % OPSIZ != 0)
30 ((unsigned char *) dstp)[0] = c;
35 /* Write 8 `op_t' per iteration until less than 8 `op_t' remain. */
36 xlen = len / (OPSIZ * 8);
39 ((op_t *) dstp)[0] = cccc;
40 ((op_t *) dstp)[1] = cccc;
41 ((op_t *) dstp)[2] = cccc;
42 ((op_t *) dstp)[3] = cccc;
43 ((op_t *) dstp)[4] = cccc;
44 ((op_t *) dstp)[5] = cccc;
45 ((op_t *) dstp)[6] = cccc;
46 ((op_t *) dstp)[7] = cccc;
52 /* Write 1 `op_t' per iteration until less than OPSIZ bytes remain. */
56 ((op_t *) dstp)[0] = cccc;
63 /* Write the last few bytes. */
66 ((unsigned char *) dstp)[0] = c;