From owner-svn-src-all@FreeBSD.ORG Mon Nov 17 18:45:08 2008 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 624461065670; Mon, 17 Nov 2008 18:45:08 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 4B8C38FC19; Mon, 17 Nov 2008 18:45:08 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id mAHIj8pT089998; Mon, 17 Nov 2008 18:45:08 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id mAHIj7Wr089992; Mon, 17 Nov 2008 18:45:07 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <200811171845.mAHIj7Wr089992@svn.freebsd.org> From: Konstantin Belousov Date: Mon, 17 Nov 2008 18:45:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r185025 - in stable/7: include lib/libc lib/libc/string X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 17 Nov 2008 18:45:08 -0000 Author: kib Date: Mon Nov 17 18:45:07 2008 New Revision: 185025 URL: http://svn.freebsd.org/changeset/base/185025 Log: MFC r184587: Add the ffsll and flsll functions. These are ffs and fls operating on long long arguments. Approved by: re (kensmith) Added: stable/7/lib/libc/string/ffsll.c - copied unchanged from r184587, head/lib/libc/string/ffsll.c stable/7/lib/libc/string/flsll.c - copied unchanged from r184587, head/lib/libc/string/flsll.c Modified: stable/7/include/ (props changed) stable/7/include/strings.h stable/7/lib/libc/ (props changed) stable/7/lib/libc/string/Makefile.inc stable/7/lib/libc/string/Symbol.map stable/7/lib/libc/string/ffs.3 Modified: stable/7/include/strings.h ============================================================================== --- stable/7/include/strings.h Mon Nov 17 16:37:04 2008 (r185024) +++ stable/7/include/strings.h Mon Nov 17 18:45:07 2008 (r185025) @@ -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: stable/7/lib/libc/string/Makefile.inc ============================================================================== --- stable/7/lib/libc/string/Makefile.inc Mon Nov 17 16:37:04 2008 (r185024) +++ stable/7/lib/libc/string/Makefile.inc Mon Nov 17 18:45:07 2008 (r185025) @@ -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: stable/7/lib/libc/string/Symbol.map ============================================================================== --- stable/7/lib/libc/string/Symbol.map Mon Nov 17 16:37:04 2008 (r185024) +++ stable/7/lib/libc/string/Symbol.map Mon Nov 17 18:45:07 2008 (r185025) @@ -78,6 +78,8 @@ FBSD_1.0 { }; FBSD_1.1 { + ffsll; + flsll; memrchr; }; Modified: stable/7/lib/libc/string/ffs.3 ============================================================================== --- stable/7/lib/libc/string/ffs.3 Mon Nov 17 16:37:04 2008 (r185024) +++ stable/7/lib/libc/string/ffs.3 Mon Nov 17 18:45:07 2008 (r185025) @@ -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: stable/7/lib/libc/string/ffsll.c (from r184587, head/lib/libc/string/ffsll.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/7/lib/libc/string/ffsll.c Mon Nov 17 18:45:07 2008 (r185025, copy of r184587, head/lib/libc/string/ffsll.c) @@ -0,0 +1,48 @@ +/*- + * Copyright (c) 1990, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include + +/* + * Find First Set bit + */ +int +ffsll(long long mask) +{ + int bit; + + if (mask == 0) + return (0); + for (bit = 1; !(mask & 1); bit++) + mask = (unsigned long long)mask >> 1; + return (bit); +} Copied: stable/7/lib/libc/string/flsll.c (from r184587, head/lib/libc/string/flsll.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/7/lib/libc/string/flsll.c Mon Nov 17 18:45:07 2008 (r185025, copy of r184587, head/lib/libc/string/flsll.c) @@ -0,0 +1,48 @@ +/*- + * Copyright (c) 1990, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include + +/* + * Find Last Set bit + */ +int +flsll(long long mask) +{ + int bit; + + if (mask == 0) + return (0); + for (bit = 1; mask != 1; bit++) + mask = (unsigned long long)mask >> 1; + return (bit); +}