svn commit: r184587 - in head: include lib/libc/string
Konstantin Belousov
kib at FreeBSD.org
Mon Nov 3 02:22:20 PST 2008
Author: kib
Date: Mon Nov 3 10:22:19 2008
New Revision: 184587
URL: http://svn.freebsd.org/changeset/base/184587
Log:
Add the ffsll and flsll functions. These are ffs and fls operating
on long long arguments.
Reviewed by: bde (previous version, that included asm implementation
for all ffs and fls functions on i386 and amd64)
MFC after: 2 weeks
Added:
head/lib/libc/string/ffsll.c (contents, props changed)
- copied, changed from r184585, head/lib/libc/string/ffs.c
head/lib/libc/string/flsll.c (contents, props changed)
- copied, changed from r184585, head/lib/libc/string/fls.c
Modified:
head/include/strings.h
head/lib/libc/string/Makefile.inc
head/lib/libc/string/Symbol.map
head/lib/libc/string/ffs.3
Modified: head/include/strings.h
==============================================================================
--- head/include/strings.h Mon Nov 3 10:14:47 2008 (r184586)
+++ head/include/strings.h Mon Nov 3 10:22:19 2008 (r184587)
@@ -44,8 +44,10 @@ void bzero(void *, size_t); /* LEGA
int ffs(int) __pure2;
#ifdef __BSD_VISIBLE
int ffsl(long) __pure2;
+int ffsll(long long) __pure2;
int fls(int) __pure2;
int flsl(long) __pure2;
+int flsll(long long) __pure2;
#endif
char *index(const char *, int) __pure; /* LEGACY */
char *rindex(const char *, int) __pure; /* LEGACY */
Modified: head/lib/libc/string/Makefile.inc
==============================================================================
--- head/lib/libc/string/Makefile.inc Mon Nov 3 10:14:47 2008 (r184586)
+++ head/lib/libc/string/Makefile.inc Mon Nov 3 10:22:19 2008 (r184587)
@@ -6,8 +6,8 @@
CFLAGS+= -I${.CURDIR}/locale
# machine-independent string sources
-MISRCS+=bcmp.c bcopy.c bzero.c ffs.c ffsl.c fls.c flsl.c index.c memccpy.c \
- memchr.c memrchr.c memcmp.c \
+MISRCS+=bcmp.c bcopy.c bzero.c ffs.c ffsl.c ffsll.c fls.c flsl.c flsll.c \
+ index.c memccpy.c memchr.c memrchr.c memcmp.c \
memcpy.c memmem.c memmove.c memset.c rindex.c stpcpy.c strcasecmp.c \
strcat.c strchr.c strcmp.c strcoll.c strcpy.c strcspn.c strdup.c \
strerror.c strlcat.c strlcpy.c strlen.c strmode.c strncat.c strncmp.c \
@@ -38,6 +38,8 @@ MAN+= bcmp.3 bcopy.3 bstring.3 bzero.3 f
MLINKS+=ffs.3 ffsl.3
MLINKS+=ffs.3 fls.3
MLINKS+=ffs.3 flsl.3
+MLINKS+=ffs.3 ffsll.3
+MLINKS+=ffs.3 flsll.3
MLINKS+=index.3 rindex.3
MLINKS+=memchr.3 memrchr.3
MLINKS+=strcasecmp.3 strncasecmp.3
Modified: head/lib/libc/string/Symbol.map
==============================================================================
--- head/lib/libc/string/Symbol.map Mon Nov 3 10:14:47 2008 (r184586)
+++ head/lib/libc/string/Symbol.map Mon Nov 3 10:22:19 2008 (r184587)
@@ -78,6 +78,8 @@ FBSD_1.0 {
};
FBSD_1.1 {
+ ffsll;
+ flsll;
memrchr;
};
Modified: head/lib/libc/string/ffs.3
==============================================================================
--- head/lib/libc/string/ffs.3 Mon Nov 3 10:14:47 2008 (r184586)
+++ head/lib/libc/string/ffs.3 Mon Nov 3 10:22:19 2008 (r184587)
@@ -30,14 +30,16 @@
.\" @(#)ffs.3 8.2 (Berkeley) 4/19/94
.\" $FreeBSD$
.\"
-.Dd October 12, 2006
+.Dd October 26, 2008
.Dt FFS 3
.Os
.Sh NAME
.Nm ffs ,
.Nm ffsl ,
+.Nm ffsll ,
.Nm fls ,
-.Nm flsl
+.Nm flsl ,
+.Nm flsll
.Nd find first or last bit set in a bit string
.Sh LIBRARY
.Lb libc
@@ -48,14 +50,19 @@
.Ft int
.Fn ffsl "long value"
.Ft int
+.Ft int
+.Fn ffsll "long long value"
.Fn fls "int value"
.Ft int
.Fn flsl "long value"
+.Ft int
+.Fn flsll "long long value"
.Sh DESCRIPTION
The
-.Fn ffs
-and
+.Fn ffs ,
.Fn ffsl
+and
+.Fn ffsll
functions find the first bit set
(beginning with the least significant bit)
in
@@ -63,9 +70,10 @@ in
and return the index of that bit.
.Pp
The
-.Fn fls
-and
+.Fn fls ,
.Fn flsl
+and
+.Fn flsll
functions find the last bit set in
.Fa value
and return the index of that bit.
@@ -95,3 +103,9 @@ and
.Fn flsl
functions appeared in
.Fx 5.3 .
+The
+.Fn ffsll
+and
+.Fn flsll
+functions appeared in
+.Fx 8.0 .
Copied and modified: head/lib/libc/string/ffsll.c (from r184585, head/lib/libc/string/ffs.c)
==============================================================================
--- head/lib/libc/string/ffs.c Mon Nov 3 07:52:18 2008 (r184585, copy source)
+++ head/lib/libc/string/ffsll.c Mon Nov 3 10:22:19 2008 (r184587)
@@ -27,9 +27,6 @@
* SUCH DAMAGE.
*/
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)ffs.c 8.1 (Berkeley) 6/4/93";
-#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
@@ -39,13 +36,13 @@ __FBSDID("$FreeBSD$");
* Find First Set bit
*/
int
-ffs(int mask)
+ffsll(long long mask)
{
int bit;
if (mask == 0)
- return(0);
+ return (0);
for (bit = 1; !(mask & 1); bit++)
- mask = (unsigned int)mask >> 1;
+ mask = (unsigned long long)mask >> 1;
return (bit);
}
Copied and modified: head/lib/libc/string/flsll.c (from r184585, head/lib/libc/string/fls.c)
==============================================================================
--- head/lib/libc/string/fls.c Mon Nov 3 07:52:18 2008 (r184585, copy source)
+++ head/lib/libc/string/flsll.c Mon Nov 3 10:22:19 2008 (r184587)
@@ -36,13 +36,13 @@ __FBSDID("$FreeBSD$");
* Find Last Set bit
*/
int
-fls(int mask)
+flsll(long long mask)
{
int bit;
if (mask == 0)
return (0);
for (bit = 1; mask != 1; bit++)
- mask = (unsigned int)mask >> 1;
+ mask = (unsigned long long)mask >> 1;
return (bit);
}
More information about the svn-src-all
mailing list