1
/* @(#)cmpnullbytes.c 1.2 03/06/15 Copyright 1988,2002-2003 J. Schilling */
4
"@(#)cmpnullbytes.c 1.2 03/06/15 Copyright 1988,2002-2003 J. Schilling";
7
* compare data against null
9
* Copyright (c) 1988,2002-2003 J. Schilling
12
* This program is free software; you can redistribute it and/or modify
13
* it under the terms of the GNU General Public License as published by
14
* the Free Software Foundation; either version 2, or (at your option)
17
* This program is distributed in the hope that it will be useful,
18
* but WITHOUT ANY WARRANTY; without even the implied warranty of
19
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
* GNU General Public License for more details.
22
* You should have received a copy of the GNU General Public License along with
23
* this program; see the file COPYING. If not, write to the Free Software
24
* Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
31
#define DO8(a) a; a; a; a; a; a; a; a;
34
cmpnullbytes(fromp, cnt)
38
register const char *from = (char *)fromp;
42
* If we change cnt to be unsigned, check for == instead of <=
48
* Compare byte-wise until properly aligned for a long pointer.
50
while (--n >= 0 && !laligned(from)) {
56
if (n >= (int)(8 * sizeof (long))) {
58
register const long *froml = (const long *)from;
59
register int rem = n % (8 * sizeof (long));
61
n /= (8 * sizeof (long));
71
from = (const char *)froml;
74
from = (const char *)froml;
85
} while ((n -= 8) >= 0);
106
return (--from - (char *)fromp);