From: Brian Foster <bfoster@redhat.com>
To: Dave Chinner <david@fromorbit.com>
Cc: xfs@oss.sgi.com
Subject: Re: [PATCH] libxfs: add xfs_bit.c
Date: Wed, 24 Jun 2015 09:00:36 -0400 [thread overview]
Message-ID: <20150624130035.GA1888@bfoster.bfoster> (raw)
In-Reply-To: <1434932648-19120-1-git-send-email-david@fromorbit.com>
On Mon, Jun 22, 2015 at 10:24:08AM +1000, Dave Chinner wrote:
> From: Dave Chinner <dchinner@redhat.com>
>
> The header side of xfs_bit.c is already in libxfs, and the sparse
> inode code requires the xfs_next_bit() function so pull in the
> xfs_bit.c file so that a sparse inode enabled libxfs compiles
> cleanly in userspace.
>
> Signed-off-by: Dave Chinner <dchinner@redhat.com>
> ---
Reviewed-by: Brian Foster <bfoster@redhat.com>
> fs/xfs/Makefile | 2 +-
> fs/xfs/libxfs/xfs_bit.c | 118 ++++++++++++++++++++++++++++++++++++++++++++++++
> fs/xfs/xfs_bit.c | 118 ------------------------------------------------
> 3 files changed, 119 insertions(+), 119 deletions(-)
> create mode 100644 fs/xfs/libxfs/xfs_bit.c
> delete mode 100644 fs/xfs/xfs_bit.c
>
> diff --git a/fs/xfs/Makefile b/fs/xfs/Makefile
> index b346326..2fbf910 100644
> --- a/fs/xfs/Makefile
> +++ b/fs/xfs/Makefile
> @@ -33,6 +33,7 @@ xfs-y += $(addprefix libxfs/, \
> xfs_attr.o \
> xfs_attr_leaf.o \
> xfs_attr_remote.o \
> + xfs_bit.o \
> xfs_bmap.o \
> xfs_bmap_btree.o \
> xfs_btree.o \
> @@ -63,7 +64,6 @@ xfs-$(CONFIG_XFS_RT) += $(addprefix libxfs/, \
> xfs-y += xfs_aops.o \
> xfs_attr_inactive.o \
> xfs_attr_list.o \
> - xfs_bit.o \
> xfs_bmap_util.o \
> xfs_buf.o \
> xfs_dir2_readdir.o \
> diff --git a/fs/xfs/libxfs/xfs_bit.c b/fs/xfs/libxfs/xfs_bit.c
> new file mode 100644
> index 0000000..0e8885a
> --- /dev/null
> +++ b/fs/xfs/libxfs/xfs_bit.c
> @@ -0,0 +1,118 @@
> +/*
> + * Copyright (c) 2000-2005 Silicon Graphics, Inc.
> + * All Rights Reserved.
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License as
> + * published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope that it would be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, write the Free Software Foundation,
> + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
> + */
> +#include "xfs.h"
> +#include "xfs_log_format.h"
> +#include "xfs_bit.h"
> +
> +/*
> + * XFS bit manipulation routines, used in non-realtime code.
> + */
> +
> +/*
> + * Return whether bitmap is empty.
> + * Size is number of words in the bitmap, which is padded to word boundary
> + * Returns 1 for empty, 0 for non-empty.
> + */
> +int
> +xfs_bitmap_empty(uint *map, uint size)
> +{
> + uint i;
> + uint ret = 0;
> +
> + for (i = 0; i < size; i++) {
> + ret |= map[i];
> + }
> +
> + return (ret == 0);
> +}
> +
> +/*
> + * Count the number of contiguous bits set in the bitmap starting with bit
> + * start_bit. Size is the size of the bitmap in words.
> + */
> +int
> +xfs_contig_bits(uint *map, uint size, uint start_bit)
> +{
> + uint * p = ((unsigned int *) map) + (start_bit >> BIT_TO_WORD_SHIFT);
> + uint result = 0;
> + uint tmp;
> +
> + size <<= BIT_TO_WORD_SHIFT;
> +
> + ASSERT(start_bit < size);
> + size -= start_bit & ~(NBWORD - 1);
> + start_bit &= (NBWORD - 1);
> + if (start_bit) {
> + tmp = *p++;
> + /* set to one first offset bits prior to start */
> + tmp |= (~0U >> (NBWORD-start_bit));
> + if (tmp != ~0U)
> + goto found;
> + result += NBWORD;
> + size -= NBWORD;
> + }
> + while (size) {
> + if ((tmp = *p++) != ~0U)
> + goto found;
> + result += NBWORD;
> + size -= NBWORD;
> + }
> + return result - start_bit;
> +found:
> + return result + ffz(tmp) - start_bit;
> +}
> +
> +/*
> + * This takes the bit number to start looking from and
> + * returns the next set bit from there. It returns -1
> + * if there are no more bits set or the start bit is
> + * beyond the end of the bitmap.
> + *
> + * Size is the number of words, not bytes, in the bitmap.
> + */
> +int xfs_next_bit(uint *map, uint size, uint start_bit)
> +{
> + uint * p = ((unsigned int *) map) + (start_bit >> BIT_TO_WORD_SHIFT);
> + uint result = start_bit & ~(NBWORD - 1);
> + uint tmp;
> +
> + size <<= BIT_TO_WORD_SHIFT;
> +
> + if (start_bit >= size)
> + return -1;
> + size -= result;
> + start_bit &= (NBWORD - 1);
> + if (start_bit) {
> + tmp = *p++;
> + /* set to zero first offset bits prior to start */
> + tmp &= (~0U << start_bit);
> + if (tmp != 0U)
> + goto found;
> + result += NBWORD;
> + size -= NBWORD;
> + }
> + while (size) {
> + if ((tmp = *p++) != 0U)
> + goto found;
> + result += NBWORD;
> + size -= NBWORD;
> + }
> + return -1;
> +found:
> + return result + ffs(tmp) - 1;
> +}
> diff --git a/fs/xfs/xfs_bit.c b/fs/xfs/xfs_bit.c
> deleted file mode 100644
> index 0e8885a..0000000
> --- a/fs/xfs/xfs_bit.c
> +++ /dev/null
> @@ -1,118 +0,0 @@
> -/*
> - * Copyright (c) 2000-2005 Silicon Graphics, Inc.
> - * All Rights Reserved.
> - *
> - * This program is free software; you can redistribute it and/or
> - * modify it under the terms of the GNU General Public License as
> - * published by the Free Software Foundation.
> - *
> - * This program is distributed in the hope that it would be useful,
> - * but WITHOUT ANY WARRANTY; without even the implied warranty of
> - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> - * GNU General Public License for more details.
> - *
> - * You should have received a copy of the GNU General Public License
> - * along with this program; if not, write the Free Software Foundation,
> - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
> - */
> -#include "xfs.h"
> -#include "xfs_log_format.h"
> -#include "xfs_bit.h"
> -
> -/*
> - * XFS bit manipulation routines, used in non-realtime code.
> - */
> -
> -/*
> - * Return whether bitmap is empty.
> - * Size is number of words in the bitmap, which is padded to word boundary
> - * Returns 1 for empty, 0 for non-empty.
> - */
> -int
> -xfs_bitmap_empty(uint *map, uint size)
> -{
> - uint i;
> - uint ret = 0;
> -
> - for (i = 0; i < size; i++) {
> - ret |= map[i];
> - }
> -
> - return (ret == 0);
> -}
> -
> -/*
> - * Count the number of contiguous bits set in the bitmap starting with bit
> - * start_bit. Size is the size of the bitmap in words.
> - */
> -int
> -xfs_contig_bits(uint *map, uint size, uint start_bit)
> -{
> - uint * p = ((unsigned int *) map) + (start_bit >> BIT_TO_WORD_SHIFT);
> - uint result = 0;
> - uint tmp;
> -
> - size <<= BIT_TO_WORD_SHIFT;
> -
> - ASSERT(start_bit < size);
> - size -= start_bit & ~(NBWORD - 1);
> - start_bit &= (NBWORD - 1);
> - if (start_bit) {
> - tmp = *p++;
> - /* set to one first offset bits prior to start */
> - tmp |= (~0U >> (NBWORD-start_bit));
> - if (tmp != ~0U)
> - goto found;
> - result += NBWORD;
> - size -= NBWORD;
> - }
> - while (size) {
> - if ((tmp = *p++) != ~0U)
> - goto found;
> - result += NBWORD;
> - size -= NBWORD;
> - }
> - return result - start_bit;
> -found:
> - return result + ffz(tmp) - start_bit;
> -}
> -
> -/*
> - * This takes the bit number to start looking from and
> - * returns the next set bit from there. It returns -1
> - * if there are no more bits set or the start bit is
> - * beyond the end of the bitmap.
> - *
> - * Size is the number of words, not bytes, in the bitmap.
> - */
> -int xfs_next_bit(uint *map, uint size, uint start_bit)
> -{
> - uint * p = ((unsigned int *) map) + (start_bit >> BIT_TO_WORD_SHIFT);
> - uint result = start_bit & ~(NBWORD - 1);
> - uint tmp;
> -
> - size <<= BIT_TO_WORD_SHIFT;
> -
> - if (start_bit >= size)
> - return -1;
> - size -= result;
> - start_bit &= (NBWORD - 1);
> - if (start_bit) {
> - tmp = *p++;
> - /* set to zero first offset bits prior to start */
> - tmp &= (~0U << start_bit);
> - if (tmp != 0U)
> - goto found;
> - result += NBWORD;
> - size -= NBWORD;
> - }
> - while (size) {
> - if ((tmp = *p++) != 0U)
> - goto found;
> - result += NBWORD;
> - size -= NBWORD;
> - }
> - return -1;
> -found:
> - return result + ffs(tmp) - 1;
> -}
> --
> 2.0.0
>
> _______________________________________________
> xfs mailing list
> xfs@oss.sgi.com
> http://oss.sgi.com/mailman/listinfo/xfs
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
prev parent reply other threads:[~2015-06-24 13:00 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-22 0:24 [PATCH] libxfs: add xfs_bit.c Dave Chinner
2015-06-24 13:00 ` Brian Foster [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150624130035.GA1888@bfoster.bfoster \
--to=bfoster@redhat.com \
--cc=david@fromorbit.com \
--cc=xfs@oss.sgi.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.