1 typedef __SIZE_TYPE__
size_t;
2 static int mymemcmp1 (unsigned long int, unsigned long int)
3 __attribute__ ((__nothrow__
));
6 mymemcmp1 (unsigned long int a
, unsigned long int b
)
8 long int srcp1
= (long int) &a
;
9 long int srcp2
= (long int) &b
;
10 unsigned long int a0
, b0
;
13 a0
= ((unsigned char *) srcp1
)[0];
14 b0
= ((unsigned char *) srcp2
)[0];
22 static int mymemcmp2 (long, long, size_t) __attribute__ ((__nothrow__
));
25 mymemcmp2 (long int srcp1
, long int srcp2
, size_t len
)
27 unsigned long int a0
, a1
;
28 unsigned long int b0
, b1
;
33 a0
= ((unsigned long int *) srcp1
)[0];
34 b0
= ((unsigned long int *) srcp2
)[0];
35 srcp1
-= 2 * (sizeof (unsigned long int));
36 srcp2
-= 2 * (sizeof (unsigned long int));
40 a1
= ((unsigned long int *) srcp1
)[0];
41 b1
= ((unsigned long int *) srcp2
)[0];
42 srcp1
-= (sizeof (unsigned long int));
43 srcp2
-= (sizeof (unsigned long int));
47 if (16 <= 3 * (sizeof (unsigned long int)) && len
== 0)
49 a0
= ((unsigned long int *) srcp1
)[0];
50 b0
= ((unsigned long int *) srcp2
)[0];
53 a1
= ((unsigned long int *) srcp1
)[0];
54 b1
= ((unsigned long int *) srcp2
)[0];
55 srcp1
+= (sizeof (unsigned long int));
56 srcp2
+= (sizeof (unsigned long int));
58 if (16 <= 3 * (sizeof (unsigned long int)) && len
== 0)
63 a0
= ((unsigned long int *) srcp1
)[0];
64 b0
= ((unsigned long int *) srcp2
)[0];
66 return mymemcmp1 ((a1
), (b1
));
68 a1
= ((unsigned long int *) srcp1
)[1];
69 b1
= ((unsigned long int *) srcp2
)[1];
71 return mymemcmp1 ((a0
), (b0
));
73 a0
= ((unsigned long int *) srcp1
)[2];
74 b0
= ((unsigned long int *) srcp2
)[2];
76 return mymemcmp1 ((a1
), (b1
));
78 a1
= ((unsigned long int *) srcp1
)[3];
79 b1
= ((unsigned long int *) srcp2
)[3];
81 return mymemcmp1 ((a0
), (b0
));
82 srcp1
+= 4 * (sizeof (unsigned long int));
83 srcp2
+= 4 * (sizeof (unsigned long int));
89 return mymemcmp1 ((a1
), (b1
));
93 static int mymemcmp3 (long, long, size_t) __attribute__ ((__nothrow__
));
96 mymemcmp3 (long int srcp1
, long int srcp2
, size_t len
)
98 unsigned long int a0
, a1
, a2
, a3
;
99 unsigned long int b0
, b1
, b2
, b3
;
102 shl
= 8 * (srcp1
% (sizeof (unsigned long int)));
103 shr
= 8 * (sizeof (unsigned long int)) - shl
;
104 srcp1
&= -(sizeof (unsigned long int));
109 a1
= ((unsigned long int *) srcp1
)[0];
110 a2
= ((unsigned long int *) srcp1
)[1];
111 b2
= ((unsigned long int *) srcp2
)[0];
112 srcp1
-= 1 * (sizeof (unsigned long int));
113 srcp2
-= 2 * (sizeof (unsigned long int));
117 a0
= ((unsigned long int *) srcp1
)[0];
118 a1
= ((unsigned long int *) srcp1
)[1];
119 b1
= ((unsigned long int *) srcp2
)[0];
120 srcp2
-= 1 * (sizeof (unsigned long int));
124 if (16 <= 3 * (sizeof (unsigned long int)) && len
== 0)
126 a3
= ((unsigned long int *) srcp1
)[0];
127 a0
= ((unsigned long int *) srcp1
)[1];
128 b0
= ((unsigned long int *) srcp2
)[0];
129 srcp1
+= 1 * (sizeof (unsigned long int));
132 a2
= ((unsigned long int *) srcp1
)[0];
133 a3
= ((unsigned long int *) srcp1
)[1];
134 b3
= ((unsigned long int *) srcp2
)[0];
135 srcp1
+= 2 * (sizeof (unsigned long int));
136 srcp2
+= 1 * (sizeof (unsigned long int));
138 if (16 <= 3 * (sizeof (unsigned long int)) && len
== 0)
143 a0
= ((unsigned long int *) srcp1
)[0];
144 b0
= ((unsigned long int *) srcp2
)[0];
145 x
= (((a2
) >> (shl
)) | ((a3
) << (shr
)));
147 return mymemcmp1 ((x
), (b3
));
149 a1
= ((unsigned long int *) srcp1
)[1];
150 b1
= ((unsigned long int *) srcp2
)[1];
151 x
= (((a3
) >> (shl
)) | ((a0
) << (shr
)));
153 return mymemcmp1 ((x
), (b0
));
155 a2
= ((unsigned long int *) srcp1
)[2];
156 b2
= ((unsigned long int *) srcp2
)[2];
157 x
= (((a0
) >> (shl
)) | ((a1
) << (shr
)));
159 return mymemcmp1 ((x
), (b1
));
161 a3
= ((unsigned long int *) srcp1
)[3];
162 b3
= ((unsigned long int *) srcp2
)[3];
163 x
= (((a1
) >> (shl
)) | ((a2
) << (shr
)));
165 return mymemcmp1 ((x
), (b2
));
166 srcp1
+= 4 * (sizeof (unsigned long int));
167 srcp2
+= 4 * (sizeof (unsigned long int));
172 x
= (((a2
) >> (shl
)) | ((a3
) << (shr
)));
174 return mymemcmp1 ((x
), (b3
));
178 __attribute__ ((noinline
))
179 int mymemcmp (const void *s1
, const void *s2
, size_t len
)
181 unsigned long int a0
;
182 unsigned long int b0
;
183 long int srcp1
= (long int) s1
;
184 long int srcp2
= (long int) s2
;
185 if (srcp1
% (sizeof (unsigned long int)) == 0)
186 return mymemcmp2 (srcp1
, srcp2
, len
/ (sizeof (unsigned long int)));
188 return mymemcmp3 (srcp1
, srcp2
, len
/ (sizeof (unsigned long int)));
197 union { long int l
; char c
[sizeof (long int)]; } u
;
199 /* The test above assumes little endian and long being the same size
201 if (sizeof (long int) != sizeof (void *) || sizeof (long int) < 4)
204 if (u
.c
[0] != 0x78 || u
.c
[1] != 0x56 || u
.c
[2] != 0x34 || u
.c
[3] != 0x12)
207 p
= buf
+ 16 - (((long int) buf
) & 15);
208 __builtin_memcpy (p
+ 9,
209 "\x1\x37\x82\xa7\x55\x49\x9d\xbf\xf8\x44\xb6\x55\x17\x8e\xf9", 15);
210 __builtin_memcpy (p
+ 128 + 24,
211 "\x1\x37\x82\xa7\x55\x49\xd0\xf3\xb7\x2a\x6d\x23\x71\x49\x6a", 15);
212 if (mymemcmp (p
+ 9, p
+ 128 + 24, 33) != -51)