1 /* @(#)zerobytes.c 1.2 11/07/30 Copyright Copyright 1987, 1995-2011 J. Schilling */
3 * fill memory with null bytes
5 * Copyright (c) 1987, 1995-2011 J. Schilling
8 * The contents of this file are subject to the terms of the
9 * Common Development and Distribution License, Version 1.0 only
10 * (the "License"). You may not use this file except in compliance
13 * See the file CDDL.Schily.txt in this distribution for details.
15 * When distributing Covered Code, include this CDDL HEADER in each
16 * file and include the License file CDDL.Schily.txt from this distribution.
19 #include <schily/standard.h>
20 #include <schily/align.h>
21 #include <schily/types.h>
22 #include <schily/schily.h>
24 #define DO8(a) a; a; a; a; a; a; a; a;
34 register char *to
= (char *)tov
;
36 register long lval
= 0L;
39 * If we change cnt to be unsigned, check for == instead of <=
44 if (n
< 8 * sizeof (long)) { /* Simple may be faster... */
45 do { /* n is always > 0 */
52 * Assign byte-wise until properly aligned for a long pointer.
54 while (--n
>= 0 && !laligned(to
)) {
59 if (n
>= (ssize_t
)(8 * sizeof (long))) {
60 register ssize_t rem
= n
% (8 * sizeof (long));
62 n
/= (8 * sizeof (long));
64 register long *tol
= (long *)to
;
78 } while ((n
-= 8) >= 0);