2009年6月25日星期四

fls 2.6.4 bug

Do you discover any problem in the following code?

c->space_bits = fls(c->leb_size) - 3;
c->lpt_lnum_bits = fls(c->lpt_lebs);
c->lpt_offs_bits = fls(c->leb_size - 1);
c->lpt_spc_bits = fls(c->leb_size);
n = DIV_ROUND_UP(c->max_leb_cnt, UBIFS_LPT_FANOUT);
c->pcnt_bits = fls(n - 1)

This bug is inside the inline assmeble marco fls, you can not discover it in the C-level.

Let see the fls marco,
2.6.4 include/asm-arm/bitops.h
#define fls(x) \
( __builtin_constant_p(x) ? generic_fls(x) : \
({ int __r; asm("clz%?\t%0, %1" : "=r"(__r) : "r"(x)); 32-__r; }) )

clz, count the number of leading zero,
%0, result register
%1, operand register
"=r", output to C varaible
"r", input from C varaible

Since the clz instruction may alter the code register, so the following divion may be incorrect. There is a fix in 2.6.2x, which put "cc" in the Clobber List, it tell compiler there is a chance the cc will be changed by the inline asemble code.

2.6.2x arm/include/asm/bitops.h
static inline int fls(int x)
{
int ret;
if (__builtin_constant_p(x))
return constant_fls(x);

asm("clz\t%0, %1" : "=r" (ret) : "r" (x) : "cc");
ret = 32 - ret;
return ret;
}

2009年6月18日星期四

不方便的pantry


幾日前公司既阿姐同係咁講公司既pantry 好唔掂,講到有火添....其實我用左咁耐都
只係發現到一個唔方便既地方,真係慚愧。

請看看以上簡陋的圖,想一想到到地這個pantry有幾多不方便的地方呢?

過幾日開估...哈哈

=======================================================
第一個係水係放係門後面,
當門打開的時候,卙唔到水
當門關上的候候,可以卙水,不過有人開門既時候會撞到你

第二個係垃圾筒離洗手盤太遠
咁洗完碗d殘渣就會留係洗手盤 ,d人唔會咁有手尾返去垃圾筒

第三個係電水煲太近洗手盤
d人洗完碗就順手law食水來用,好快無晒

2009年6月15日星期一

敢輸都要敢嬴

身邊越來越多朋友將手上既股票沽出,每當佢地問我放唔放好,仲唔放呀?
我都係好悶好悶個幾句
一d股都唔會放
咩時候會放?
2628 100蚊 5 200蚊

有時唔明,d人係3萬6點買貨,跌到萬一你唔放,你敢坐敢輸,但係升到萬8,唔洗輸咁多,或者嬴少少,你就仆到去放貨......如果係咁你會嬴到大錢咩?

大家唔好覺得升到呢個位就無得升,尤其係2628,即使短期會跌,但係28,27呢d位,
又係機會入貨,短期目標價33,中期36, 遠期100,要知道2628不會設止蝕 = = ,因為一定賺。