diff options
Diffstat (limited to 'lib/libc/arch/ns32k/string/bzero.c')
-rw-r--r-- | lib/libc/arch/ns32k/string/bzero.c | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/lib/libc/arch/ns32k/string/bzero.c b/lib/libc/arch/ns32k/string/bzero.c new file mode 100644 index 00000000000..7e0c16cc87e --- /dev/null +++ b/lib/libc/arch/ns32k/string/bzero.c @@ -0,0 +1,73 @@ +/* + * Mach Operating System + * Copyright (c) 1991,1990,1989 Carnegie Mellon University + * All Rights Reserved. + * + * Permission to use, copy, modify and distribute this software and its + * documentation is hereby granted, provided that both the copyright + * notice and this permission notice appear in all copies of the + * software, derivative works or modified versions, and any portions + * thereof, and that both notices appear in supporting documentation. + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR + * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. + * + * Carnegie Mellon requests users of this software to return to + * + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU + * School of Computer Science + * Carnegie Mellon University + * Pittsburgh PA 15213-3890 + * + * any improvements or extensions that they make and grant Carnegie Mellon + * the rights to redistribute these changes. + */ +/* + * $Id: bzero.c,v 1.1.1.1 1995/10/18 08:41:38 deraadt Exp $ + */ +/* + * Object: + * bzero EXPORTED function + * + * Clear memory locations + * + * Optimize for aligned memory ops, if possible and simple. + * Might need later recoding in assembly for better efficiency. + */ +void +bzero(addr, bcount) + register unsigned addr; + register unsigned bcount; +{ + register int i; + + if (bcount == 0) /* sanity */ + return; + switch (addr & 3) { + case 1: + *((char *) addr++) = 0; + if (--bcount == 0) + return; + case 2: + *((char *) addr++) = 0; + if (--bcount == 0) + return; + case 3: + *((char *) addr++) = 0; + if (--bcount == 0) + return; + default: + break; + } + + for (i = bcount >> 2; i; i--, addr += 4) + *((int *) addr) = 0; + + switch (bcount & 3) { + case 3: *((char*)addr++) = 0; + case 2: *((char*)addr++) = 0; + case 1: *((char*)addr++) = 0; + default:break; + } +} |