use the ffs32 from bitops.h which is faster
This commit is contained in:
parent
cf1c3898fb
commit
2f1af36850
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: ffs.c,v 1.2 2007/06/04 18:19:27 christos Exp $ */
|
/* $NetBSD: ffs.c,v 1.3 2007/11/02 21:05:06 christos Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1990, 1993
|
* Copyright (c) 1990, 1993
|
||||||
@ -34,10 +34,13 @@
|
|||||||
#if 0
|
#if 0
|
||||||
static char sccsid[] = "@(#)ffs.c 8.1 (Berkeley) 6/4/93";
|
static char sccsid[] = "@(#)ffs.c 8.1 (Berkeley) 6/4/93";
|
||||||
#else
|
#else
|
||||||
__RCSID("$NetBSD: ffs.c,v 1.2 2007/06/04 18:19:27 christos Exp $");
|
__RCSID("$NetBSD: ffs.c,v 1.3 2007/11/02 21:05:06 christos Exp $");
|
||||||
#endif
|
#endif
|
||||||
#endif /* LIBC_SCCS and not lint */
|
#endif /* LIBC_SCCS and not lint */
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/bitops.h>
|
||||||
|
|
||||||
#if !defined(_KERNEL) && !defined(_STANDALONE)
|
#if !defined(_KERNEL) && !defined(_STANDALONE)
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#else
|
#else
|
||||||
@ -53,11 +56,5 @@ __RCSID("$NetBSD: ffs.c,v 1.2 2007/06/04 18:19:27 christos Exp $");
|
|||||||
int
|
int
|
||||||
ffs(int mask)
|
ffs(int mask)
|
||||||
{
|
{
|
||||||
int bit;
|
return ffs32((uint32_t)mask);
|
||||||
|
|
||||||
if (mask == 0)
|
|
||||||
return(0);
|
|
||||||
for (bit = 1; !(mask & 1); bit++)
|
|
||||||
mask >>= 1;
|
|
||||||
return(bit);
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user