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

Comparing libecb/ecb.h (file contents):
Revision 1.147 by root, Fri Oct 17 12:25:01 2014 UTC vs.
Revision 1.149 by root, Fri Oct 24 04:54:11 2014 UTC

278 #define ECB_MEMORY_FENCE_RELEASE ECB_MEMORY_FENCE 278 #define ECB_MEMORY_FENCE_RELEASE ECB_MEMORY_FENCE
279#endif 279#endif
280 280
281/*****************************************************************************/ 281/*****************************************************************************/
282 282
283#if __cplusplus 283#if ECB_CPP
284 #define ecb_inline static inline 284 #define ecb_inline static inline
285#elif ECB_GCC_VERSION(2,5) 285#elif ECB_GCC_VERSION(2,5)
286 #define ecb_inline static __inline__ 286 #define ecb_inline static __inline__
287#elif ECB_C99 287#elif ECB_C99
288 #define ecb_inline static inline 288 #define ecb_inline static inline
343#elif ECB_GCC_VERSION(3,0) || ECB_CLANG_VERSION(2,8) 343#elif ECB_GCC_VERSION(3,0) || ECB_CLANG_VERSION(2,8)
344 #define ecb_decltype(x) __typeof__ (x) 344 #define ecb_decltype(x) __typeof__ (x)
345#endif 345#endif
346 346
347#if _MSC_VER >= 1300 347#if _MSC_VER >= 1300
348 #define ecb_deprecated __declspec(deprecated) 348 #define ecb_deprecated __declspec (deprecated)
349#else 349#else
350 #define ecb_deprecated ecb_attribute ((__deprecated__)) 350 #define ecb_deprecated ecb_attribute ((__deprecated__))
351#endif 351#endif
352 352
353#define ecb_noinline ecb_attribute ((__noinline__)) 353#define ecb_noinline ecb_attribute ((__noinline__))
600 #define ecb_mod(m,n) ((m) % (n) + ((m) % (n) < 0 ? (n) : 0)) 600 #define ecb_mod(m,n) ((m) % (n) + ((m) % (n) < 0 ? (n) : 0))
601#else 601#else
602 #define ecb_mod(m,n) ((m) < 0 ? ((n) - 1 - ((-1 - (m)) % (n))) : ((m) % (n))) 602 #define ecb_mod(m,n) ((m) < 0 ? ((n) - 1 - ((-1 - (m)) % (n))) : ((m) % (n)))
603#endif 603#endif
604 604
605#if __cplusplus 605#if ECB_CPP
606 template<typename T> 606 template<typename T>
607 static inline T ecb_div_rd (T val, T div) 607 static inline T ecb_div_rd (T val, T div)
608 { 608 {
609 return val < 0 ? - ((-val + div - 1) / div) : (val ) / div; 609 return val < 0 ? - ((-val + div - 1) / div) : (val ) / div;
610 } 610 }
670 #define ECB_NAN NAN 670 #define ECB_NAN NAN
671 #else 671 #else
672 #define ECB_NAN ECB_INFINITY 672 #define ECB_NAN ECB_INFINITY
673 #endif 673 #endif
674 674
675 #if ECB_C99 || _XOPEN_VERSION >= 600 || _POSIX_VERSION >= 200112L
676 #define ecb_ldexpf(x,e) ldexpf (x, e)
677 #else
678 #define ecb_ldexpf(x,e) (float) ldexp ((double)(x), e)
679 #endif
680
675 /* converts an ieee half/binary16 to a float */ 681 /* converts an ieee half/binary16 to a float */
676 ecb_function_ float ecb_binary16_to_float (uint16_t x) ecb_const; 682 ecb_function_ float ecb_binary16_to_float (uint16_t x) ecb_const;
677 ecb_function_ float 683 ecb_function_ float
678 ecb_binary16_to_float (uint16_t x) 684 ecb_binary16_to_float (uint16_t x)
679 { 685 {
680 int e = (x >> 10) & 0x1f; 686 int e = (x >> 10) & 0x1f;
681 int m = x & 0x3ff; 687 int m = x & 0x3ff;
682 float r; 688 float r;
683 689
684 if (!e ) r = ldexpf (m , -24); 690 if (!e ) r = ecb_ldexpf (m , -24);
685 else if (e != 31) r = ldexpf (m + 0x400, e - 25); 691 else if (e != 31) r = ecb_ldexpf (m + 0x400, e - 25);
686 else if (m ) r = ECB_NAN; 692 else if (m ) r = ECB_NAN;
687 else r = ECB_INFINITY; 693 else r = ECB_INFINITY;
688 694
689 return x & 0x8000 ? -r : r; 695 return x & 0x8000 ? -r : r;
690 } 696 }
749 x |= 0x800000U; 755 x |= 0x800000U;
750 else 756 else
751 e = 1; 757 e = 1;
752 758
753 /* we distrust ldexpf a bit and do the 2**-24 scaling by an extra multiply */ 759 /* we distrust ldexpf a bit and do the 2**-24 scaling by an extra multiply */
754 r = ldexpf (x * (0.5f / 0x800000U), e - 126); 760 r = ecb_ldexpf (x * (0.5f / 0x800000U), e - 126);
755 761
756 r = neg ? -r : r; 762 r = neg ? -r : r;
757 #endif 763 #endif
758 764
759 return r; 765 return r;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines