This source file includes following definitions.
- memset
1
2
3
4
5
6
7
8
9
10 #include <linux/types.h>
11 #include <linux/string.h>
12
13 void *memset(void *s, int c, size_t count)
14 {
15 int destptr, charcnt, dwordcnt, fill8reg, wrkrega;
16
17 if (!count)
18 return s;
19
20 c &= 0xFF;
21
22 if (count <= 8) {
23 char *xs = (char *) s;
24
25 while (count--)
26 *xs++ = c;
27 return s;
28 }
29
30 __asm__ __volatile__ (
31
32 " slli %4, %5, 8\n"
33 " or %4, %4, %5\n"
34 " slli %3, %4, 16\n"
35 " or %3, %3, %4\n"
36
37 " andi %4, %0, 0x01\n"
38 " beq %4, zero, 1f\n"
39 " addi %1, %1, -1\n"
40 " stb %3, 0(%0)\n"
41 " addi %0, %0, 1\n"
42 "1: mov %2, %1\n"
43
44 " andi %4, %0, 0x02\n"
45 " beq %4, zero, 2f\n"
46 " addi %1, %1, -2\n"
47 " sth %3, 0(%0)\n"
48 " addi %0, %0, 2\n"
49 " mov %2, %1\n"
50
51 "2: srli %2, %2, 2\n"
52
53 "3: stw %3, 0(%0)\n"
54 " addi %0, %0, 4\n"
55 " addi %2, %2, -1\n"
56 " bne %2, zero, 3b\n"
57
58 " andi %4, %1, 0x02\n"
59 " beq %4, zero, 4f\n"
60 " sth %3, 0(%0)\n"
61 " addi %0, %0, 2\n"
62
63 "4: andi %4, %1, 0x01\n"
64 " beq %4, zero, 5f\n"
65 " stb %3, 0(%0)\n"
66 "5:\n"
67 : "=r" (destptr),
68 "=r" (charcnt),
69 "=r" (dwordcnt),
70 "=r" (fill8reg),
71 "=&r" (wrkrega)
72 : "r" (c),
73 "0" (s),
74 "1" (count)
75 : "memory"
76 );
77
78 return s;
79 }