Sync usage with man page.
[netbsd-mini2440.git] / lib / libc / pc532 / string / bzero.c
blob8ac1d3952c3679c08a902644cfe8bc0c0084922b
1 /*
2 * Mach Operating System
3 * Copyright (c) 1991,1990,1989 Carnegie Mellon University
4 * All Rights Reserved.
5 *
6 * Permission to use, copy, modify and distribute this software and its
7 * documentation is hereby granted, provided that both the copyright
8 * notice and this permission notice appear in all copies of the
9 * software, derivative works or modified versions, and any portions
10 * thereof, and that both notices appear in supporting documentation.
12 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
13 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
14 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
16 * Carnegie Mellon requests users of this software to return to
18 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
19 * School of Computer Science
20 * Carnegie Mellon University
21 * Pittsburgh PA 15213-3890
23 * any improvements or extensions that they make and grant Carnegie Mellon
24 * the rights to redistribute these changes.
27 * $Id: bzero.c,v 1.1 1993/09/17 18:43:47 phil Exp $
30 * Object:
31 * bzero EXPORTED function
33 * Clear memory locations
35 * Optimize for aligned memory ops, if possible and simple.
36 * Might need later recoding in assembly for better efficiency.
38 void
39 bzero(addr, bcount)
40 register unsigned addr;
41 register unsigned bcount;
43 register int i;
45 if (bcount == 0) /* sanity */
46 return;
47 switch (addr & 3) {
48 case 1:
49 *((char *) addr++) = 0;
50 if (--bcount == 0)
51 return;
52 case 2:
53 *((char *) addr++) = 0;
54 if (--bcount == 0)
55 return;
56 case 3:
57 *((char *) addr++) = 0;
58 if (--bcount == 0)
59 return;
60 default:
61 break;
64 for (i = bcount >> 2; i; i--, addr += 4)
65 *((int *) addr) = 0;
67 switch (bcount & 3) {
68 case 3: *((char*)addr++) = 0;
69 case 2: *((char*)addr++) = 0;
70 case 1: *((char*)addr++) = 0;
71 default:break;