Mercurial > gnulib
annotate lib/memcmp.c @ 17363:5a51fb7777a9
sys_select, sys_time: port 2013-01-30 Solaris 2.6 fix to Cygwin
Problem reported by Marco Atzeri in
<http://lists.gnu.org/archive/html/bug-gnulib/2013-03/msg00000.html>.
* lib/sys_select.in.h [HAVE_SYS_SELECT_H && _CYGWIN_SYS_TIME_H]:
Simply delegate to the system <sys/select.h> in this case too.
Also, pay attention to _GL_SYS_SELECT_H_REDIRECT_FROM_SYS_TIME_H only
if OSF/1, since otherwise Cygwin breaks, and it doesn't seem to
be needed on Solaris either.
* lib/sys_time.in.h [_CYGWIN_SYS_TIME_H]:
Simply delgate to the system <sys/time.h> in this case.
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Tue, 19 Mar 2013 09:08:47 -0700 |
parents | e542fd46ad6f |
children | 344018b6e5d7 |
rev | line source |
---|---|
17249
e542fd46ad6f
maint: update all copyright year number ranges
Eric Blake <eblake@redhat.com>
parents:
16235
diff
changeset
|
1 /* Copyright (C) 1991, 1993, 1995, 1997-1998, 2003, 2006, 2009-2013 Free |
12559
c2cbabec01dd
update nearly all FSF copyright year lists to include 2010
Jim Meyering <meyering@redhat.com>
parents:
12518
diff
changeset
|
2 Software Foundation, Inc. |
4664 | 3 |
387 | 4 Contributed by Torbjorn Granlund (tege@sics.se). |
5 | |
1112 | 6 NOTE: The canonical source of this file is maintained with the GNU C Library. |
7 Bugs can be reported to bug-glibc@prep.ai.mit.edu. | |
387 | 8 |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
7302
diff
changeset
|
9 This program is free software: you can redistribute it and/or modify it |
1112 | 10 under the terms of the GNU General Public License as published by the |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
7302
diff
changeset
|
11 Free Software Foundation; either version 3 of the License, or any |
1112 | 12 later version. |
387 | 13 |
1112 | 14 This program is distributed in the hope that it will be useful, |
15 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 GNU General Public License for more details. | |
387 | 18 |
1112 | 19 You should have received a copy of the GNU General Public License |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
7302
diff
changeset
|
20 along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
387 | 21 |
7302
8a1a9361108c
* _fpending.c: Include <config.h> unconditionally, since we no
Paul Eggert <eggert@cs.ucla.edu>
parents:
6259
diff
changeset
|
22 #ifndef _LIBC |
6259
96c32553b4c6
Use a consistent style for including <config.h>.
Paul Eggert <eggert@cs.ucla.edu>
parents:
5848
diff
changeset
|
23 # include <config.h> |
387 | 24 #endif |
25 | |
4664 | 26 #include <string.h> |
387 | 27 |
11106
1cc89f3c5e6b
Fix use of integer types in memcmp.c.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
28 #include <stdint.h> |
1cc89f3c5e6b
Fix use of integer types in memcmp.c.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
29 |
1112 | 30 #undef memcmp |
31 | |
387 | 32 #ifdef _LIBC |
33 | |
1112 | 34 # include <memcopy.h> |
2934 | 35 # include <endian.h> |
36 | |
37 # if __BYTE_ORDER == __BIG_ENDIAN | |
38 # define WORDS_BIGENDIAN | |
39 # endif | |
387 | 40 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11106
diff
changeset
|
41 #else /* Not in the GNU C library. */ |
387 | 42 |
1112 | 43 # include <sys/types.h> |
387 | 44 |
45 /* Type to use for aligned memory operations. | |
46 This should normally be the biggest type supported by a single load | |
47 and store. Must be an unsigned type. */ | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11106
diff
changeset
|
48 # define op_t unsigned long int |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11106
diff
changeset
|
49 # define OPSIZ (sizeof(op_t)) |
387 | 50 |
51 /* Threshold value for when to enter the unrolled loops. */ | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11106
diff
changeset
|
52 # define OP_T_THRES 16 |
387 | 53 |
54 /* Type to use for unaligned operations. */ | |
55 typedef unsigned char byte; | |
56 | |
1112 | 57 # ifndef WORDS_BIGENDIAN |
58 # define MERGE(w0, sh_1, w1, sh_2) (((w0) >> (sh_1)) | ((w1) << (sh_2))) | |
59 # else | |
60 # define MERGE(w0, sh_1, w1, sh_2) (((w0) << (sh_1)) | ((w1) >> (sh_2))) | |
61 # endif | |
387 | 62 |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11106
diff
changeset
|
63 #endif /* In the GNU C library. */ |
387 | 64 |
65 #ifdef WORDS_BIGENDIAN | |
1112 | 66 # define CMP_LT_OR_GT(a, b) ((a) > (b) ? 1 : -1) |
387 | 67 #else |
12845
ad16dedc2e1d
removing useless parentheses in cpp #define directives
Jim Meyering <meyering@redhat.com>
parents:
12559
diff
changeset
|
68 # define CMP_LT_OR_GT(a, b) memcmp_bytes (a, b) |
387 | 69 #endif |
70 | |
71 /* BE VERY CAREFUL IF YOU CHANGE THIS CODE! */ | |
72 | |
73 /* The strategy of this memcmp is: | |
74 | |
75 1. Compare bytes until one of the block pointers is aligned. | |
76 | |
77 2. Compare using memcmp_common_alignment or | |
78 memcmp_not_common_alignment, regarding the alignment of the other | |
79 block after the initial byte operations. The maximum number of | |
80 full words (of type op_t) are compared in this way. | |
81 | |
82 3. Compare the few remaining bytes. */ | |
83 | |
84 #ifndef WORDS_BIGENDIAN | |
85 /* memcmp_bytes -- Compare A and B bytewise in the byte order of the machine. | |
86 A and B are known to be different. | |
87 This is needed only on little-endian machines. */ | |
1112 | 88 |
89 # ifdef __GNUC__ | |
387 | 90 __inline |
1112 | 91 # endif |
387 | 92 static int |
11106
1cc89f3c5e6b
Fix use of integer types in memcmp.c.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
93 memcmp_bytes (op_t a, op_t b) |
387 | 94 { |
11106
1cc89f3c5e6b
Fix use of integer types in memcmp.c.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
95 const byte *srcp1 = (const byte *) &a; |
1cc89f3c5e6b
Fix use of integer types in memcmp.c.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
96 const byte *srcp2 = (const byte *) &b; |
387 | 97 op_t a0, b0; |
98 | |
99 do | |
100 { | |
11106
1cc89f3c5e6b
Fix use of integer types in memcmp.c.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
101 a0 = srcp1[0]; |
1cc89f3c5e6b
Fix use of integer types in memcmp.c.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
102 b0 = srcp2[0]; |
387 | 103 srcp1 += 1; |
104 srcp2 += 1; | |
105 } | |
106 while (a0 == b0); | |
107 return a0 - b0; | |
108 } | |
109 #endif | |
110 | |
16235
18a38c9615f0
In commentary, do not use ` to quote.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16201
diff
changeset
|
111 /* memcmp_common_alignment -- Compare blocks at SRCP1 and SRCP2 with LEN 'op_t' |
387 | 112 objects (not LEN bytes!). Both SRCP1 and SRCP2 should be aligned for |
16235
18a38c9615f0
In commentary, do not use ` to quote.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16201
diff
changeset
|
113 memory operations on 'op_t's. */ |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11106
diff
changeset
|
114 #ifdef __GNUC__ |
387 | 115 __inline |
116 #endif | |
117 static int | |
11106
1cc89f3c5e6b
Fix use of integer types in memcmp.c.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
118 memcmp_common_alignment (uintptr_t srcp1, uintptr_t srcp2, size_t len) |
387 | 119 { |
120 op_t a0, a1; | |
121 op_t b0, b1; | |
122 | |
123 switch (len % 4) | |
124 { | |
1112 | 125 default: /* Avoid warning about uninitialized local variables. */ |
387 | 126 case 2: |
127 a0 = ((op_t *) srcp1)[0]; | |
128 b0 = ((op_t *) srcp2)[0]; | |
129 srcp1 -= 2 * OPSIZ; | |
130 srcp2 -= 2 * OPSIZ; | |
131 len += 2; | |
132 goto do1; | |
133 case 3: | |
134 a1 = ((op_t *) srcp1)[0]; | |
135 b1 = ((op_t *) srcp2)[0]; | |
136 srcp1 -= OPSIZ; | |
137 srcp2 -= OPSIZ; | |
138 len += 1; | |
139 goto do2; | |
140 case 0: | |
141 if (OP_T_THRES <= 3 * OPSIZ && len == 0) | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11106
diff
changeset
|
142 return 0; |
387 | 143 a0 = ((op_t *) srcp1)[0]; |
144 b0 = ((op_t *) srcp2)[0]; | |
145 goto do3; | |
146 case 1: | |
147 a1 = ((op_t *) srcp1)[0]; | |
148 b1 = ((op_t *) srcp2)[0]; | |
149 srcp1 += OPSIZ; | |
150 srcp2 += OPSIZ; | |
151 len -= 1; | |
152 if (OP_T_THRES <= 3 * OPSIZ && len == 0) | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11106
diff
changeset
|
153 goto do0; |
387 | 154 /* Fall through. */ |
155 } | |
156 | |
157 do | |
158 { | |
159 a0 = ((op_t *) srcp1)[0]; | |
160 b0 = ((op_t *) srcp2)[0]; | |
161 if (a1 != b1) | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11106
diff
changeset
|
162 return CMP_LT_OR_GT (a1, b1); |
387 | 163 |
164 do3: | |
165 a1 = ((op_t *) srcp1)[1]; | |
166 b1 = ((op_t *) srcp2)[1]; | |
167 if (a0 != b0) | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11106
diff
changeset
|
168 return CMP_LT_OR_GT (a0, b0); |
387 | 169 |
170 do2: | |
171 a0 = ((op_t *) srcp1)[2]; | |
172 b0 = ((op_t *) srcp2)[2]; | |
173 if (a1 != b1) | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11106
diff
changeset
|
174 return CMP_LT_OR_GT (a1, b1); |
387 | 175 |
176 do1: | |
177 a1 = ((op_t *) srcp1)[3]; | |
178 b1 = ((op_t *) srcp2)[3]; | |
179 if (a0 != b0) | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11106
diff
changeset
|
180 return CMP_LT_OR_GT (a0, b0); |
387 | 181 |
182 srcp1 += 4 * OPSIZ; | |
183 srcp2 += 4 * OPSIZ; | |
184 len -= 4; | |
185 } | |
186 while (len != 0); | |
187 | |
188 /* This is the right position for do0. Please don't move | |
189 it into the loop. */ | |
190 do0: | |
191 if (a1 != b1) | |
192 return CMP_LT_OR_GT (a1, b1); | |
193 return 0; | |
194 } | |
195 | |
196 /* memcmp_not_common_alignment -- Compare blocks at SRCP1 and SRCP2 with LEN | |
16235
18a38c9615f0
In commentary, do not use ` to quote.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16201
diff
changeset
|
197 'op_t' objects (not LEN bytes!). SRCP2 should be aligned for memory |
18a38c9615f0
In commentary, do not use ` to quote.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16201
diff
changeset
|
198 operations on 'op_t', but SRCP1 *should be unaligned*. */ |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11106
diff
changeset
|
199 #ifdef __GNUC__ |
387 | 200 __inline |
201 #endif | |
202 static int | |
11106
1cc89f3c5e6b
Fix use of integer types in memcmp.c.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
203 memcmp_not_common_alignment (uintptr_t srcp1, uintptr_t srcp2, size_t len) |
387 | 204 { |
205 op_t a0, a1, a2, a3; | |
206 op_t b0, b1, b2, b3; | |
207 op_t x; | |
208 int shl, shr; | |
209 | |
210 /* Calculate how to shift a word read at the memory operation | |
211 aligned srcp1 to make it aligned for comparison. */ | |
212 | |
213 shl = 8 * (srcp1 % OPSIZ); | |
214 shr = 8 * OPSIZ - shl; | |
215 | |
16235
18a38c9615f0
In commentary, do not use ` to quote.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16201
diff
changeset
|
216 /* Make SRCP1 aligned by rounding it down to the beginning of the 'op_t' |
387 | 217 it points in the middle of. */ |
218 srcp1 &= -OPSIZ; | |
219 | |
220 switch (len % 4) | |
221 { | |
1112 | 222 default: /* Avoid warning about uninitialized local variables. */ |
387 | 223 case 2: |
224 a1 = ((op_t *) srcp1)[0]; | |
225 a2 = ((op_t *) srcp1)[1]; | |
226 b2 = ((op_t *) srcp2)[0]; | |
227 srcp1 -= 1 * OPSIZ; | |
228 srcp2 -= 2 * OPSIZ; | |
229 len += 2; | |
230 goto do1; | |
231 case 3: | |
232 a0 = ((op_t *) srcp1)[0]; | |
233 a1 = ((op_t *) srcp1)[1]; | |
234 b1 = ((op_t *) srcp2)[0]; | |
235 srcp2 -= 1 * OPSIZ; | |
236 len += 1; | |
237 goto do2; | |
238 case 0: | |
239 if (OP_T_THRES <= 3 * OPSIZ && len == 0) | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11106
diff
changeset
|
240 return 0; |
387 | 241 a3 = ((op_t *) srcp1)[0]; |
242 a0 = ((op_t *) srcp1)[1]; | |
243 b0 = ((op_t *) srcp2)[0]; | |
244 srcp1 += 1 * OPSIZ; | |
245 goto do3; | |
246 case 1: | |
247 a2 = ((op_t *) srcp1)[0]; | |
248 a3 = ((op_t *) srcp1)[1]; | |
249 b3 = ((op_t *) srcp2)[0]; | |
250 srcp1 += 2 * OPSIZ; | |
251 srcp2 += 1 * OPSIZ; | |
252 len -= 1; | |
253 if (OP_T_THRES <= 3 * OPSIZ && len == 0) | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11106
diff
changeset
|
254 goto do0; |
387 | 255 /* Fall through. */ |
256 } | |
257 | |
258 do | |
259 { | |
260 a0 = ((op_t *) srcp1)[0]; | |
261 b0 = ((op_t *) srcp2)[0]; | |
13051 | 262 x = MERGE (a2, shl, a3, shr); |
387 | 263 if (x != b3) |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11106
diff
changeset
|
264 return CMP_LT_OR_GT (x, b3); |
387 | 265 |
266 do3: | |
267 a1 = ((op_t *) srcp1)[1]; | |
268 b1 = ((op_t *) srcp2)[1]; | |
13051 | 269 x = MERGE (a3, shl, a0, shr); |
387 | 270 if (x != b0) |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11106
diff
changeset
|
271 return CMP_LT_OR_GT (x, b0); |
387 | 272 |
273 do2: | |
274 a2 = ((op_t *) srcp1)[2]; | |
275 b2 = ((op_t *) srcp2)[2]; | |
13051 | 276 x = MERGE (a0, shl, a1, shr); |
387 | 277 if (x != b1) |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11106
diff
changeset
|
278 return CMP_LT_OR_GT (x, b1); |
387 | 279 |
280 do1: | |
281 a3 = ((op_t *) srcp1)[3]; | |
282 b3 = ((op_t *) srcp2)[3]; | |
13051 | 283 x = MERGE (a1, shl, a2, shr); |
387 | 284 if (x != b2) |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11106
diff
changeset
|
285 return CMP_LT_OR_GT (x, b2); |
387 | 286 |
287 srcp1 += 4 * OPSIZ; | |
288 srcp2 += 4 * OPSIZ; | |
289 len -= 4; | |
290 } | |
291 while (len != 0); | |
292 | |
293 /* This is the right position for do0. Please don't move | |
294 it into the loop. */ | |
295 do0: | |
13051 | 296 x = MERGE (a2, shl, a3, shr); |
387 | 297 if (x != b3) |
298 return CMP_LT_OR_GT (x, b3); | |
299 return 0; | |
300 } | |
301 | |
302 int | |
1557 | 303 rpl_memcmp (const void *s1, const void *s2, size_t len) |
387 | 304 { |
305 op_t a0; | |
306 op_t b0; | |
11106
1cc89f3c5e6b
Fix use of integer types in memcmp.c.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
307 uintptr_t srcp1 = (uintptr_t) s1; |
1cc89f3c5e6b
Fix use of integer types in memcmp.c.
Bruno Haible <bruno@clisp.org>
parents:
9309
diff
changeset
|
308 uintptr_t srcp2 = (uintptr_t) s2; |
387 | 309 op_t res; |
310 | |
311 if (len >= OP_T_THRES) | |
312 { | |
313 /* There are at least some bytes to compare. No need to test | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11106
diff
changeset
|
314 for LEN == 0 in this alignment loop. */ |
387 | 315 while (srcp2 % OPSIZ != 0) |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11106
diff
changeset
|
316 { |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11106
diff
changeset
|
317 a0 = ((byte *) srcp1)[0]; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11106
diff
changeset
|
318 b0 = ((byte *) srcp2)[0]; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11106
diff
changeset
|
319 srcp1 += 1; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11106
diff
changeset
|
320 srcp2 += 1; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11106
diff
changeset
|
321 res = a0 - b0; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11106
diff
changeset
|
322 if (res != 0) |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11106
diff
changeset
|
323 return res; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11106
diff
changeset
|
324 len -= 1; |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11106
diff
changeset
|
325 } |
387 | 326 |
16235
18a38c9615f0
In commentary, do not use ` to quote.
Paul Eggert <eggert@cs.ucla.edu>
parents:
16201
diff
changeset
|
327 /* SRCP2 is now aligned for memory operations on 'op_t'. |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11106
diff
changeset
|
328 SRCP1 alignment determines if we can do a simple, |
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11106
diff
changeset
|
329 aligned compare or need to shuffle bits. */ |
387 | 330 |
331 if (srcp1 % OPSIZ == 0) | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11106
diff
changeset
|
332 res = memcmp_common_alignment (srcp1, srcp2, len / OPSIZ); |
387 | 333 else |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11106
diff
changeset
|
334 res = memcmp_not_common_alignment (srcp1, srcp2, len / OPSIZ); |
387 | 335 if (res != 0) |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11106
diff
changeset
|
336 return res; |
387 | 337 |
338 /* Number of bytes remaining in the interval [0..OPSIZ-1]. */ | |
339 srcp1 += len & -OPSIZ; | |
340 srcp2 += len & -OPSIZ; | |
341 len %= OPSIZ; | |
342 } | |
343 | |
344 /* There are just a few bytes to compare. Use byte memory operations. */ | |
345 while (len != 0) | |
346 { | |
347 a0 = ((byte *) srcp1)[0]; | |
348 b0 = ((byte *) srcp2)[0]; | |
349 srcp1 += 1; | |
350 srcp2 += 1; | |
351 res = a0 - b0; | |
352 if (res != 0) | |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
11106
diff
changeset
|
353 return res; |
387 | 354 len -= 1; |
355 } | |
356 | |
357 return 0; | |
358 } | |
776 | 359 |
360 #ifdef weak_alias | |
1112 | 361 # undef bcmp |
776 | 362 weak_alias (memcmp, bcmp) |
363 #endif |