… | |
… | |
352 | #define ecb_deprecated __declspec (deprecated) |
352 | #define ecb_deprecated __declspec (deprecated) |
353 | #else |
353 | #else |
354 | #define ecb_deprecated ecb_attribute ((__deprecated__)) |
354 | #define ecb_deprecated ecb_attribute ((__deprecated__)) |
355 | #endif |
355 | #endif |
356 | |
356 | |
357 | #if __MSC_VER >= 1500 |
357 | #if _MSC_VER >= 1500 |
358 | #define ecb_deprecated_message(msg) __declspec (deprecated (msg)) |
358 | #define ecb_deprecated_message(msg) __declspec (deprecated (msg)) |
359 | #elif ECB_GCC_VERSION(4,5) |
359 | #elif ECB_GCC_VERSION(4,5) |
360 | #define ecb_deprecated_message(msg) ecb_attribute ((__deprecated__ (msg)) |
360 | #define ecb_deprecated_message(msg) ecb_attribute ((__deprecated__ (msg)) |
361 | #else |
361 | #else |
362 | #define ecb_deprecated_message(msg) ecb_deprecated |
362 | #define ecb_deprecated_message(msg) ecb_deprecated |
… | |
… | |
547 | ecb_inline ecb_const uint32_t ecb_rotr32 (uint32_t x, unsigned int count) { return (x << (32 - count)) | (x >> count); } |
547 | ecb_inline ecb_const uint32_t ecb_rotr32 (uint32_t x, unsigned int count) { return (x << (32 - count)) | (x >> count); } |
548 | ecb_inline ecb_const uint64_t ecb_rotl64 (uint64_t x, unsigned int count) { return (x >> (64 - count)) | (x << count); } |
548 | ecb_inline ecb_const uint64_t ecb_rotl64 (uint64_t x, unsigned int count) { return (x >> (64 - count)) | (x << count); } |
549 | ecb_inline ecb_const uint64_t ecb_rotr64 (uint64_t x, unsigned int count) { return (x << (64 - count)) | (x >> count); } |
549 | ecb_inline ecb_const uint64_t ecb_rotr64 (uint64_t x, unsigned int count) { return (x << (64 - count)) | (x >> count); } |
550 | |
550 | |
551 | #if ECB_GCC_VERSION(4,3) || (ECB_CLANG_BUILTIN(__builtin_bswap32) && ECB_CLANG_BUILTIN(__builtin_bswap64)) |
551 | #if ECB_GCC_VERSION(4,3) || (ECB_CLANG_BUILTIN(__builtin_bswap32) && ECB_CLANG_BUILTIN(__builtin_bswap64)) |
|
|
552 | #if ECB_GCC_VERSION(4,8) || ECB_CLANG_BUILTIN(__builtin_bswap16) |
|
|
553 | #define ecb_bswap16(x) __builtin_bswap16 (x) |
|
|
554 | #else |
552 | #define ecb_bswap16(x) (__builtin_bswap32 (x) >> 16) |
555 | #define ecb_bswap16(x) (__builtin_bswap32 (x) >> 16) |
|
|
556 | #endif |
553 | #define ecb_bswap32(x) __builtin_bswap32 (x) |
557 | #define ecb_bswap32(x) __builtin_bswap32 (x) |
554 | #define ecb_bswap64(x) __builtin_bswap64 (x) |
558 | #define ecb_bswap64(x) __builtin_bswap64 (x) |
|
|
559 | #elif _MSC_VER |
|
|
560 | #include <stdlib.h> |
|
|
561 | #define ecb_bswap16(x) ((uint16_t)_byteswap_ushort ((uint16_t)(x))) |
|
|
562 | #define ecb_bswap32(x) ((uint32_t)_byteswap_ulong ((uint32_t)(x))) |
|
|
563 | #define ecb_bswap64(x) ((uint64_t)_byteswap_uint64 ((uint64_t)(x))) |
555 | #else |
564 | #else |
556 | ecb_function_ ecb_const uint16_t ecb_bswap16 (uint16_t x); |
565 | ecb_function_ ecb_const uint16_t ecb_bswap16 (uint16_t x); |
557 | ecb_function_ ecb_const uint16_t |
566 | ecb_function_ ecb_const uint16_t |
558 | ecb_bswap16 (uint16_t x) |
567 | ecb_bswap16 (uint16_t x) |
559 | { |
568 | { |
… | |
… | |
693 | #define ECB_NAN ECB_INFINITY |
702 | #define ECB_NAN ECB_INFINITY |
694 | #endif |
703 | #endif |
695 | |
704 | |
696 | #if ECB_C99 || _XOPEN_VERSION >= 600 || _POSIX_VERSION >= 200112L |
705 | #if ECB_C99 || _XOPEN_VERSION >= 600 || _POSIX_VERSION >= 200112L |
697 | #define ecb_ldexpf(x,e) ldexpf ((x), (e)) |
706 | #define ecb_ldexpf(x,e) ldexpf ((x), (e)) |
|
|
707 | #define ecb_frexpf(x,e) frexpf ((x), (e)) |
698 | #else |
708 | #else |
699 | #define ecb_ldexpf(x,e) (float) ldexp ((float) (x), (e)) |
709 | #define ecb_ldexpf(x,e) (float) ldexp ((double) (x), (e)) |
|
|
710 | #define ecb_frexpf(x,e) (float) frexp ((double) (x), (e)) |
700 | #endif |
711 | #endif |
701 | |
712 | |
702 | /* converts an ieee half/binary16 to a float */ |
713 | /* converts an ieee half/binary16 to a float */ |
703 | ecb_function_ ecb_const float ecb_binary16_to_float (uint16_t x); |
714 | ecb_function_ ecb_const float ecb_binary16_to_float (uint16_t x); |
704 | ecb_function_ ecb_const float |
715 | ecb_function_ ecb_const float |
… | |
… | |
733 | if (x == 0e0f ) return 0x00000000U; |
744 | if (x == 0e0f ) return 0x00000000U; |
734 | if (x > +3.40282346638528860e+38f) return 0x7f800000U; |
745 | if (x > +3.40282346638528860e+38f) return 0x7f800000U; |
735 | if (x < -3.40282346638528860e+38f) return 0xff800000U; |
746 | if (x < -3.40282346638528860e+38f) return 0xff800000U; |
736 | if (x != x ) return 0x7fbfffffU; |
747 | if (x != x ) return 0x7fbfffffU; |
737 | |
748 | |
738 | m = frexpf (x, &e) * 0x1000000U; |
749 | m = ecb_frexpf (x, &e) * 0x1000000U; |
739 | |
750 | |
740 | r = m & 0x80000000U; |
751 | r = m & 0x80000000U; |
741 | |
752 | |
742 | if (r) |
753 | if (r) |
743 | m = -m; |
754 | m = -m; |