⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bitmap.h

📁 lustre 1.6.5 source code
💻 H
字号:
/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- * vim:expandtab:shiftwidth=8:tabstop=8: * *  Copyright (C) 2007 Cluster File Systems, Inc. * *   This file is part of Lustre, http://www.lustre.org. * *   Lustre is free software; you can redistribute it and/or *   modify it under the terms of version 2 of the GNU General Public *   License as published by the Free Software Foundation. * *   Lustre is distributed in the hope that it will 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 Lustre; if not, write to the Free Software *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */#ifndef _LIBCFS_BITMAP_H_#define _LIBCFS_BITMAP_H_typedef struct {        int             size;        unsigned long   data[0];} bitmap_t;#define CFS_BITMAP_SIZE(nbits) \     (((nbits/BITS_PER_LONG)+1)*sizeof(long)+sizeof(bitmap_t))static inlinebitmap_t *ALLOCATE_BITMAP(int size){        bitmap_t *ptr;        OBD_ALLOC(ptr, CFS_BITMAP_SIZE(size));        if (ptr == NULL)                RETURN(ptr);        ptr->size = size;        RETURN (ptr);}#define FREE_BITMAP(ptr)        OBD_FREE(ptr, CFS_BITMAP_SIZE(ptr->size))static inlinevoid cfs_bitmap_set(bitmap_t *bitmap, int nbit){	set_bit(nbit, bitmap->data);}static inlinevoid cfs_bitmap_clear(bitmap_t *bitmap, int nbit){        clear_bit(nbit, bitmap->data);}static inlineint cfs_bitmap_check(bitmap_t *bitmap, int nbit){	return test_bit(nbit, bitmap->data);}/* return 0 is bitmap has none set bits */static inlineint cfs_bitmap_check_empty(bitmap_t *bitmap){        return find_first_bit(bitmap->data, bitmap->size) == bitmap->size;}#define cfs_foreach_bit(bitmap, pos) \	for((pos)=find_first_bit((bitmap)->data, bitmap->size);   \            (pos) < (bitmap)->size;                               \            (pos) = find_next_bit((bitmap)->data, (bitmap)->size, (pos)))#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -