1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19: #include <string.h>
20: #include <memcopy.h>
21:
22: void *
23: __memset_chk (dstpp, c, len, dstlen)
24: void *dstpp;
25: int c;
26: size_t len;
27: size_t dstlen;
28: {
29: if (__builtin_expect (dstlen < len, 0))
30: __chk_fail ();
31:
32: long int dstp = (long int) dstpp;
33:
34: if (len >= 8)
35: {
36: size_t xlen;
37: op_t cccc;
38:
39: cccc = (unsigned char) c;
40: cccc |= cccc << 8;
41: cccc |= cccc << 16;
42: if (OPSIZ > 4)
43:
44: cccc |= (cccc << 16) << 16;
45:
46:
47:
48: while (dstp % OPSIZ != 0)
49: {
50: ((byte *) dstp)[0] = c;
51: dstp += 1;
52: len -= 1;
53: }
54:
55:
56: xlen = len / (OPSIZ * 8);
57: while (xlen > 0)
58: {
59: ((op_t *) dstp)[0] = cccc;
60: ((op_t *) dstp)[1] = cccc;
61: ((op_t *) dstp)[2] = cccc;
62: ((op_t *) dstp)[3] = cccc;
63: ((op_t *) dstp)[4] = cccc;
64: ((op_t *) dstp)[5] = cccc;
65: ((op_t *) dstp)[6] = cccc;
66: ((op_t *) dstp)[7] = cccc;
67: dstp += 8 * OPSIZ;
68: xlen -= 1;
69: }
70: len %= OPSIZ * 8;
71:
72:
73: xlen = len / OPSIZ;
74: while (xlen > 0)
75: {
76: ((op_t *) dstp)[0] = cccc;
77: dstp += OPSIZ;
78: xlen -= 1;
79: }
80: len %= OPSIZ;
81: }
82:
83:
84: while (len > 0)
85: {
86: ((byte *) dstp)[0] = c;
87: dstp += 1;
88: len -= 1;
89: }
90:
91: return dstpp;
92: }