mirror of git://sourceware.org/git/glibc.git
Rather than using a C implementation of memset, directly call memset, which
typically has a much faster optimized implementation.
This commit is contained in:
parent
49f476f479
commit
ddcf6798d3
|
@ -1,3 +1,7 @@
|
||||||
|
2015-02-27 Wilco Dijkstra wdijkstr@arm.com
|
||||||
|
|
||||||
|
* string/bzero.c (__bzero): Call memset for performance.
|
||||||
|
|
||||||
2015-02-27 John David Anglin <dave.anglin@bell.net>
|
2015-02-27 John David Anglin <dave.anglin@bell.net>
|
||||||
|
|
||||||
* sysdeps/unix/sysv/linux/hppa/bits/fcntl.h (__O_SYNC): Change
|
* sysdeps/unix/sysv/linux/hppa/bits/fcntl.h (__O_SYNC): Change
|
||||||
|
|
|
@ -17,66 +17,13 @@
|
||||||
<http://www.gnu.org/licenses/>. */
|
<http://www.gnu.org/licenses/>. */
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <memcopy.h>
|
|
||||||
|
|
||||||
#undef __bzero
|
#undef __bzero
|
||||||
|
|
||||||
/* Set N bytes of S to 0. */
|
/* Set N bytes of S to 0. */
|
||||||
void
|
void
|
||||||
__bzero (s, len)
|
__bzero (void *s, size_t len)
|
||||||
void *s;
|
|
||||||
size_t len;
|
|
||||||
{
|
{
|
||||||
long int dstp = (long int) s;
|
memset (s, '\0', len);
|
||||||
const op_t zero = 0;
|
|
||||||
|
|
||||||
if (len >= 8)
|
|
||||||
{
|
|
||||||
size_t xlen;
|
|
||||||
|
|
||||||
/* There are at least some bytes to zero. No need to test
|
|
||||||
for LEN == 0 in this alignment loop. */
|
|
||||||
while (dstp % OPSIZ != 0)
|
|
||||||
{
|
|
||||||
((byte *) dstp)[0] = 0;
|
|
||||||
dstp += 1;
|
|
||||||
len -= 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Write 8 op_t per iteration until less than 8 op_t remain. */
|
|
||||||
xlen = len / (OPSIZ * 8);
|
|
||||||
while (xlen != 0)
|
|
||||||
{
|
|
||||||
((op_t *) dstp)[0] = zero;
|
|
||||||
((op_t *) dstp)[1] = zero;
|
|
||||||
((op_t *) dstp)[2] = zero;
|
|
||||||
((op_t *) dstp)[3] = zero;
|
|
||||||
((op_t *) dstp)[4] = zero;
|
|
||||||
((op_t *) dstp)[5] = zero;
|
|
||||||
((op_t *) dstp)[6] = zero;
|
|
||||||
((op_t *) dstp)[7] = zero;
|
|
||||||
dstp += 8 * OPSIZ;
|
|
||||||
xlen -= 1;
|
|
||||||
}
|
|
||||||
len %= OPSIZ * 8;
|
|
||||||
|
|
||||||
/* Write 1 op_t per iteration until less than op_t remain. */
|
|
||||||
xlen = len / OPSIZ;
|
|
||||||
while (xlen != 0)
|
|
||||||
{
|
|
||||||
((op_t *) dstp)[0] = zero;
|
|
||||||
dstp += OPSIZ;
|
|
||||||
xlen -= 1;
|
|
||||||
}
|
|
||||||
len %= OPSIZ;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Write the last few bytes. */
|
|
||||||
while (len != 0)
|
|
||||||
{
|
|
||||||
((byte *) dstp)[0] = 0;
|
|
||||||
dstp += 1;
|
|
||||||
len -= 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
weak_alias (__bzero, bzero)
|
weak_alias (__bzero, bzero)
|
||||||
|
|
Loading…
Reference in New Issue