/* memset -- set a block of memory to some byte value.
For Intel 80x86, x>=3.
- Copyright (C) 1991 Free Software Foundation, Inc.
+ Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc.
Contributed by Torbjorn Granlund (tege@sics.se).
The GNU C Library is free software; you can redistribute it and/or
#include <string.h>
#include <memcopy.h>
+#ifdef __GNUC__
+
PTR
DEFUN(memset, (dstpp, c, len),
PTR dstpp AND int c AND size_t len)
improves code very much indeed. */
register op_t x asm("ax");
- /* Fill X with four copies of the char we want to fill with. */
x = (unsigned char) c;
- x |= (x << 8);
- x |= (x << 16);
/* Clear the direction flag, so filling will move forward. */
asm volatile("cld");
/* This threshold value is optimal. */
if (len >= 12)
{
+ /* Fill X with four copies of the char we want to fill with. */
+ x |= (x << 8);
+ x |= (x << 16);
+
+ /* Adjust LEN for the bytes handled in the first loop. */
+ len -= (-dstp) % OPSIZ;
+
/* There are at least some bytes to set.
No need to test for LEN == 0 in this alignment loop. */
"=D" (dstp) :
"0" (dstp), "c" ((-dstp) % OPSIZ), "a" (x) :
"cx");
- len -= (-dstp) % OPSIZ;
/* Fill longwords. */
asm volatile("rep\n"
return dstpp;
}
+
+#else
+#include <sysdeps/generic/memset.c>
+#endif