ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libecb/ecb.h
(Generate patch)

Comparing libecb/ecb.h (file contents):
Revision 1.215 by root, Fri Mar 25 15:51:15 2022 UTC vs.
Revision 1.216 by root, Wed Apr 13 15:43:28 2022 UTC

535 ecb_function_ ecb_const int ecb_clz32 (uint32_t x) 535 ecb_function_ ecb_const int ecb_clz32 (uint32_t x)
536 { 536 {
537#if 1400 <= _MSC_VER && (_M_IX86 || _M_X64 || _M_IA64 || _M_ARM) 537#if 1400 <= _MSC_VER && (_M_IX86 || _M_X64 || _M_IA64 || _M_ARM)
538 unsigned long r; 538 unsigned long r;
539 _BitScanReverse (&r, x); 539 _BitScanReverse (&r, x);
540 return (int)r; 540 return 31 - (int)r;
541#else 541#else
542 542
543 /* Robert Harley's algorithm from comp.arch 1996-12-07 */ 543 /* Robert Harley's algorithm from comp.arch 1996-12-07 */
544 /* This happens to return 32 for x == 0, but the API does not support this */ 544 /* This happens to return 32 for x == 0, but the API does not support this */
545 545
570 ecb_function_ ecb_const int ecb_clz64 (uint64_t x) 570 ecb_function_ ecb_const int ecb_clz64 (uint64_t x)
571 { 571 {
572#if 1400 <= _MSC_VER && (_M_X64 || _M_IA64 || _M_ARM) 572#if 1400 <= _MSC_VER && (_M_X64 || _M_IA64 || _M_ARM)
573 unsigned long r; 573 unsigned long r;
574 _BitScanReverse64 (&r, x); 574 _BitScanReverse64 (&r, x);
575 return (int)r; 575 return 63 - (int)r;
576#else 576#else
577 uint32_t l = x >> 32; 577 uint32_t l = x >> 32;
578 int shift = l ? 0 : 32; 578 int shift = l ? 0 : 32;
579 return ecb_clz32 (l ? l : x) + shift; 579 return ecb_clz32 (l ? l : x) + shift;
580#endif 580#endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines