linux-4.4.1/__reg_op()
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
検索
|
最終更新
|
ヘルプ
|
ログイン
]
開始行:
*参照元 [#m62aa080]
#backlinks
*説明 [#vcd067d0]
-パス: [[linux-4.4.1/lib/bitmap.c]]
-FIXME: これは何?
--説明
**引数 [#ve3c9b5c]
-unsigned long *bitmap
--
-unsigned int pos
--
-int order
--
-int reg_op
--
**返り値 [#z491f938]
-int
--
**参考 [#u79c50fc]
*実装 [#oae25ad7]
enum {
REG_OP_ISFREE, /* true if region is all...
REG_OP_ALLOC, /* set all bits in regio...
REG_OP_RELEASE, /* clear all bits in reg...
};
static int __reg_op(unsigned long *bitmap, unsigned int ...
{
int nbits_reg; /* number of bits in reg...
int index; /* index first long of r...
int offset; /* bit offset region in ...
int nlongs_reg; /* num longs spanned by ...
int nbitsinlong; /* num bits of region in...
unsigned long mask; /* bitmask for one long ...
int i; /* scans bitmap by longs...
int ret = 0; /* return value */
/*
* Either nlongs_reg == 1 (for small orders that...
* or (offset == 0 && mask == ~0UL) (for larger ...
*/
nbits_reg = 1 << order;
index = pos / BITS_PER_LONG;
offset = pos - (index * BITS_PER_LONG);
nlongs_reg = BITS_TO_LONGS(nbits_reg);
nbitsinlong = min(nbits_reg, BITS_PER_LONG);
-
--[[linux-4.4.1/BITS_PER_LONG]]
/*
* Can't do "mask = (1UL << nbitsinlong) - 1", a...
* overflows if nbitsinlong == BITS_PER_LONG.
*/
mask = (1UL << (nbitsinlong - 1));
mask += mask - 1;
mask <<= offset;
switch (reg_op) {
case REG_OP_ISFREE:
for (i = 0; i < nlongs_reg; i++) {
if (bitmap[index + i] & mask)
goto done;
}
ret = 1; /* all bits in region fr...
break;
case REG_OP_ALLOC:
for (i = 0; i < nlongs_reg; i++)
bitmap[index + i] |= mask;
break;
case REG_OP_RELEASE:
for (i = 0; i < nlongs_reg; i++)
bitmap[index + i] &= ~mask;
break;
}
done:
return ret;
}
*コメント [#m2f48ff5]
終了行:
*参照元 [#m62aa080]
#backlinks
*説明 [#vcd067d0]
-パス: [[linux-4.4.1/lib/bitmap.c]]
-FIXME: これは何?
--説明
**引数 [#ve3c9b5c]
-unsigned long *bitmap
--
-unsigned int pos
--
-int order
--
-int reg_op
--
**返り値 [#z491f938]
-int
--
**参考 [#u79c50fc]
*実装 [#oae25ad7]
enum {
REG_OP_ISFREE, /* true if region is all...
REG_OP_ALLOC, /* set all bits in regio...
REG_OP_RELEASE, /* clear all bits in reg...
};
static int __reg_op(unsigned long *bitmap, unsigned int ...
{
int nbits_reg; /* number of bits in reg...
int index; /* index first long of r...
int offset; /* bit offset region in ...
int nlongs_reg; /* num longs spanned by ...
int nbitsinlong; /* num bits of region in...
unsigned long mask; /* bitmask for one long ...
int i; /* scans bitmap by longs...
int ret = 0; /* return value */
/*
* Either nlongs_reg == 1 (for small orders that...
* or (offset == 0 && mask == ~0UL) (for larger ...
*/
nbits_reg = 1 << order;
index = pos / BITS_PER_LONG;
offset = pos - (index * BITS_PER_LONG);
nlongs_reg = BITS_TO_LONGS(nbits_reg);
nbitsinlong = min(nbits_reg, BITS_PER_LONG);
-
--[[linux-4.4.1/BITS_PER_LONG]]
/*
* Can't do "mask = (1UL << nbitsinlong) - 1", a...
* overflows if nbitsinlong == BITS_PER_LONG.
*/
mask = (1UL << (nbitsinlong - 1));
mask += mask - 1;
mask <<= offset;
switch (reg_op) {
case REG_OP_ISFREE:
for (i = 0; i < nlongs_reg; i++) {
if (bitmap[index + i] & mask)
goto done;
}
ret = 1; /* all bits in region fr...
break;
case REG_OP_ALLOC:
for (i = 0; i < nlongs_reg; i++)
bitmap[index + i] |= mask;
break;
case REG_OP_RELEASE:
for (i = 0; i < nlongs_reg; i++)
bitmap[index + i] &= ~mask;
break;
}
done:
return ret;
}
*コメント [#m2f48ff5]
ページ名: