catch one more case in umult64 (Tomi Jylhä-Ollila)
This commit is contained in:
parent
2f0a406d44
commit
72eba9bf79
1
CHANGES
1
CHANGES
@ -2,6 +2,7 @@
|
|||||||
add fmt_strm
|
add fmt_strm
|
||||||
add iob_addbuf_munmap
|
add iob_addbuf_munmap
|
||||||
add socket_deferaccept
|
add socket_deferaccept
|
||||||
|
catch one more case in umult64 (Tomi Jylhä-Ollila)
|
||||||
|
|
||||||
0.26:
|
0.26:
|
||||||
fix really pathological case where io_timeouted would never
|
fix really pathological case where io_timeouted would never
|
||||||
|
@ -37,7 +37,11 @@ int umult64(uint64 a,uint64 b,uint64* c) {
|
|||||||
|
|
||||||
a=(uint64)(ahi)*blo+(uint64)(alo)*bhi;
|
a=(uint64)(ahi)*blo+(uint64)(alo)*bhi;
|
||||||
if (a>0xffffffff) return 0;
|
if (a>0xffffffff) return 0;
|
||||||
*c=(a<<32)+(uint64)(alo)*blo;
|
{
|
||||||
|
uint64 x=(uint64)(alo)*blo;
|
||||||
|
if (x+(a<<32) < x) return 0;
|
||||||
|
*c=x+(a<<32);
|
||||||
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,5 +19,7 @@ int main() {
|
|||||||
assert(imult64(-0x4000000000000000ll,2,&c)==1 && c==(int64)-0x8000000000000000ll);
|
assert(imult64(-0x4000000000000000ll,2,&c)==1 && c==(int64)-0x8000000000000000ll);
|
||||||
assert(imult64(0x3fffffffffffffffll,2,&c)==1 && c==0x7ffffffffffffffell);
|
assert(imult64(0x3fffffffffffffffll,2,&c)==1 && c==0x7ffffffffffffffell);
|
||||||
|
|
||||||
|
assert(umult64(0x0000000100000002ull,0x00000000ffffffffull,&c)==0);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -30,4 +30,7 @@
|
|||||||
19,18,17,16,15,14,13,12,11,10, \
|
19,18,17,16,15,14,13,12,11,10, \
|
||||||
9,8,7,6,5,4,3,2,1,0
|
9,8,7,6,5,4,3,2,1,0
|
||||||
|
|
||||||
|
#define COUNT(x, ...) ({ typeof (x) __fnord[] = { x, __VA_ARGS__ }; sizeof(__fnord)/sizeof(__fnord[0]); })
|
||||||
|
#define COUNT_PREFIX(x, ...) ({ typeof (x) __fnord[] = { x, __VA_ARGS__ }; sizeof(__fnord)/sizeof(__fnord[0]); }), x, __VA_ARGS__
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user