This source file includes following definitions.
- memset
1
2
3
4
5
6 #include <linux/types.h>
7
8 #define op_t unsigned long int
9 #define OPSIZ (sizeof(op_t))
10
11 typedef unsigned char byte;
12
13 void *memset(void *dstpp, char c, size_t len)
14 {
15 long int dstp = (long int) dstpp;
16
17 if (len >= 8) {
18 size_t xlen;
19 op_t cccc;
20
21 cccc = (unsigned char) c;
22 cccc |= cccc << 8;
23 cccc |= cccc << 16;
24
25
26
27 while (dstp % OPSIZ != 0) {
28 ((byte *) dstp)[0] = c;
29 dstp += 1;
30 len -= 1;
31 }
32
33
34
35
36 xlen = len / (OPSIZ * 8);
37 while (xlen > 0) {
38 ((op_t *) dstp)[0] = cccc;
39 ((op_t *) dstp)[1] = cccc;
40 ((op_t *) dstp)[2] = cccc;
41 ((op_t *) dstp)[3] = cccc;
42 ((op_t *) dstp)[4] = cccc;
43 ((op_t *) dstp)[5] = cccc;
44 ((op_t *) dstp)[6] = cccc;
45 ((op_t *) dstp)[7] = cccc;
46 dstp += 8 * OPSIZ;
47 xlen -= 1;
48 }
49 len %= OPSIZ * 8;
50
51
52
53
54 xlen = len / OPSIZ;
55 while (xlen > 0) {
56 ((op_t *) dstp)[0] = cccc;
57 dstp += OPSIZ;
58 xlen -= 1;
59 }
60 len %= OPSIZ;
61 }
62
63
64 while (len > 0) {
65 ((byte *) dstp)[0] = c;
66 dstp += 1;
67 len -= 1;
68 }
69
70 return dstpp;
71 }