SCCS-vsn: lib/libc/string/memset.c 5.8
*/
#if defined(LIBC_SCCS) && !defined(lint)
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)memset.c 5.7 (Berkeley) %G%";
+static char sccsid[] = "@(#)memset.c 5.8 (Berkeley) %G%";
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
#define wsize sizeof(u_int)
#define wmask (wsize - 1)
#define wsize sizeof(u_int)
#define wmask (wsize - 1)
+#ifdef BZERO
+void
+bzero(dst0, length)
+ void *dst0;
+ register size_t length;
+#else
void *
memset(dst0, c0, length)
void *dst0;
register int c0;
register size_t length;
void *
memset(dst0, c0, length)
void *dst0;
register int c0;
register size_t length;
{
register size_t t;
register u_int c;
{
register size_t t;
register u_int c;
/*
* If not enough words, just fill bytes. A length >= 2 words
* guarantees that at least one of them is `complete' after
/*
* If not enough words, just fill bytes. A length >= 2 words
* guarantees that at least one of them is `complete' after
*/
if (length < 3 * wsize) {
while (length != 0) {
*/
if (length < 3 * wsize) {
while (length != 0) {
+#ifdef BZERO
+ *dst++ = 0;
+#else
+#ifdef BZERO
+ return;
+#else
- if ((c = (u_char)c0) != 0) { /* Copy value into the word. */
+#ifndef BZERO
+ if ((c = (u_char)c0) != 0) { /* Fill the word. */
c = (c << 8) | c; /* u_int is 16 bits. */
c = (c << 8) | c; /* u_int is 16 bits. */
c = (c << 16) | c; /* u_int is 32 bits. */
#endif
c = (c << 16) | c; /* u_int is 32 bits. */
#endif
-#if UINT_MAX > 0xffffffff /* GCC will bitch, otherwise. */
+#if UINT_MAX > 0xffffffff
c = (c << 32) | c; /* u_int is 64 bits. */
#endif
}
c = (c << 32) | c; /* u_int is 64 bits. */
#endif
}
/* Align destination by filling in bytes. */
if ((t = (int)dst & wmask) != 0) {
t = wsize - t;
length -= t;
do {
/* Align destination by filling in bytes. */
if ((t = (int)dst & wmask) != 0) {
t = wsize - t;
length -= t;
do {
+#ifdef BZERO
+ *dst++ = 0;
+#else
} while (--t != 0);
}
/* Fill words. Length was >= 2*words so we know t >= 1 here. */
t = length / wsize;
do {
} while (--t != 0);
}
/* Fill words. Length was >= 2*words so we know t >= 1 here. */
t = length / wsize;
do {
+#ifdef BZERO
+ *(u_int *)dst = 0;
+#else
dst += wsize;
} while (--t != 0);
dst += wsize;
} while (--t != 0);
t = length & wmask;
if (t != 0)
do {
t = length & wmask;
if (t != 0)
do {
+#ifdef BZERO
+ *dst++ = 0;
+#else
+#ifdef BZERO
+ return;
+#else