… | |
… | |
566 | #else |
566 | #else |
567 | #define ECB_PTRSIZE 4 |
567 | #define ECB_PTRSIZE 4 |
568 | #endif |
568 | #endif |
569 | #endif |
569 | #endif |
570 | |
570 | |
|
|
571 | #define ECB_GCC_AMD64 (__amd64 || __amd64__ || __x86_64 || __x86_64__) |
|
|
572 | #define ECB_MSVC_AMD64 (_M_AMD64 || _M_X64) |
|
|
573 | |
571 | /* work around x32 idiocy by defining proper macros */ |
574 | /* work around x32 idiocy by defining proper macros */ |
572 | #if __amd64 || __x86_64 || _M_AMD64 || _M_X64 |
575 | #if ECB_GCC_AMD64 || ECB_MSVC_AMD64 |
573 | #if _ILP32 |
576 | #if _ILP32 |
574 | #define ECB_AMD64_X32 1 |
577 | #define ECB_AMD64_X32 1 |
575 | #else |
578 | #else |
576 | #define ECB_AMD64 1 |
579 | #define ECB_AMD64 1 |
577 | #endif |
580 | #endif |
… | |
… | |
645 | #if ECB_GCC_VERSION(2,5) || defined __INTEL_COMPILER || (__llvm__ && __GNUC__) || __SUNPRO_C >= 0x5110 || __SUNPRO_CC >= 0x5110 |
648 | #if ECB_GCC_VERSION(2,5) || defined __INTEL_COMPILER || (__llvm__ && __GNUC__) || __SUNPRO_C >= 0x5110 || __SUNPRO_CC >= 0x5110 |
646 | #if __i386 || __i386__ |
649 | #if __i386 || __i386__ |
647 | #define ECB_MEMORY_FENCE __asm__ __volatile__ ("lock; orb $0, -1(%%esp)" : : : "memory") |
650 | #define ECB_MEMORY_FENCE __asm__ __volatile__ ("lock; orb $0, -1(%%esp)" : : : "memory") |
648 | #define ECB_MEMORY_FENCE_ACQUIRE __asm__ __volatile__ ("" : : : "memory") |
651 | #define ECB_MEMORY_FENCE_ACQUIRE __asm__ __volatile__ ("" : : : "memory") |
649 | #define ECB_MEMORY_FENCE_RELEASE __asm__ __volatile__ ("") |
652 | #define ECB_MEMORY_FENCE_RELEASE __asm__ __volatile__ ("") |
650 | #elif __amd64 || __amd64__ || __x86_64 || __x86_64__ |
653 | #elif ECB_GCC_AMD64 |
651 | #define ECB_MEMORY_FENCE __asm__ __volatile__ ("mfence" : : : "memory") |
654 | #define ECB_MEMORY_FENCE __asm__ __volatile__ ("mfence" : : : "memory") |
652 | #define ECB_MEMORY_FENCE_ACQUIRE __asm__ __volatile__ ("" : : : "memory") |
655 | #define ECB_MEMORY_FENCE_ACQUIRE __asm__ __volatile__ ("" : : : "memory") |
653 | #define ECB_MEMORY_FENCE_RELEASE __asm__ __volatile__ ("") |
656 | #define ECB_MEMORY_FENCE_RELEASE __asm__ __volatile__ ("") |
654 | #elif __powerpc__ || __ppc__ || __powerpc64__ || __ppc64__ |
657 | #elif __powerpc__ || __ppc__ || __powerpc64__ || __ppc64__ |
655 | #define ECB_MEMORY_FENCE __asm__ __volatile__ ("sync" : : : "memory") |
658 | #define ECB_MEMORY_FENCE __asm__ __volatile__ ("sync" : : : "memory") |
… | |
… | |
794 | |
797 | |
795 | #define ECB_CONCAT_(a, b) a ## b |
798 | #define ECB_CONCAT_(a, b) a ## b |
796 | #define ECB_CONCAT(a, b) ECB_CONCAT_(a, b) |
799 | #define ECB_CONCAT(a, b) ECB_CONCAT_(a, b) |
797 | #define ECB_STRINGIFY_(a) # a |
800 | #define ECB_STRINGIFY_(a) # a |
798 | #define ECB_STRINGIFY(a) ECB_STRINGIFY_(a) |
801 | #define ECB_STRINGIFY(a) ECB_STRINGIFY_(a) |
|
|
802 | #define ECB_STRINGIFY_EXPR(expr) ((expr), ECB_STRINGIFY_ (expr)) |
799 | |
803 | |
800 | #define ecb_function_ ecb_inline |
804 | #define ecb_function_ ecb_inline |
801 | |
805 | |
802 | #if ECB_GCC_VERSION(3,1) || ECB_CLANG_VERSION(2,8) |
806 | #if ECB_GCC_VERSION(3,1) || ECB_CLANG_VERSION(2,8) |
803 | #define ecb_attribute(attrlist) __attribute__ (attrlist) |
807 | #define ecb_attribute(attrlist) __attribute__ (attrlist) |
… | |
… | |
840 | #define ecb_deprecated __declspec (deprecated) |
844 | #define ecb_deprecated __declspec (deprecated) |
841 | #else |
845 | #else |
842 | #define ecb_deprecated ecb_attribute ((__deprecated__)) |
846 | #define ecb_deprecated ecb_attribute ((__deprecated__)) |
843 | #endif |
847 | #endif |
844 | |
848 | |
|
|
849 | #if __MSC_VER >= 1500 |
|
|
850 | #define ecb_deprecated_message(msg) __declspec (deprecated (msg)) |
|
|
851 | #elif ECB_GCC_VERSION(4,5) |
|
|
852 | #define ecb_deprecated_message(msg) ecb_attribute ((__deprecated__ (msg)) |
|
|
853 | #else |
|
|
854 | #define ecb_deprecated_message(msg) ecb_deprecated |
|
|
855 | #endif |
|
|
856 | |
|
|
857 | #if _MSC_VER >= 1400 |
|
|
858 | #define ecb_noinline __declspec (noinline) |
|
|
859 | #else |
845 | #define ecb_noinline ecb_attribute ((__noinline__)) |
860 | #define ecb_noinline ecb_attribute ((__noinline__)) |
|
|
861 | #endif |
|
|
862 | |
846 | #define ecb_unused ecb_attribute ((__unused__)) |
863 | #define ecb_unused ecb_attribute ((__unused__)) |
847 | #define ecb_const ecb_attribute ((__const__)) |
864 | #define ecb_const ecb_attribute ((__const__)) |
848 | #define ecb_pure ecb_attribute ((__pure__)) |
865 | #define ecb_pure ecb_attribute ((__pure__)) |
849 | |
866 | |
850 | /* TODO http://msdn.microsoft.com/en-us/library/k6ktzx3s.aspx __declspec(noreturn) */ |
|
|
851 | #if ECB_C11 || __IBMC_NORETURN |
867 | #if ECB_C11 || __IBMC_NORETURN |
852 | /* http://pic.dhe.ibm.com/infocenter/compbg/v121v141/topic/com.ibm.xlcpp121.bg.doc/language_ref/noreturn.html */ |
868 | /* http://pic.dhe.ibm.com/infocenter/compbg/v121v141/topic/com.ibm.xlcpp121.bg.doc/language_ref/noreturn.html */ |
853 | #define ecb_noreturn _Noreturn |
869 | #define ecb_noreturn _Noreturn |
|
|
870 | #elif ECB_CPP11 |
|
|
871 | #define ecb_noreturn [[noreturn]] |
|
|
872 | #elif _MSC_VER >= 1200 |
|
|
873 | /* http://msdn.microsoft.com/en-us/library/k6ktzx3s.aspx */ |
|
|
874 | #define ecb_noreturn __declspec (noreturn) |
854 | #else |
875 | #else |
855 | #define ecb_noreturn ecb_attribute ((__noreturn__)) |
876 | #define ecb_noreturn ecb_attribute ((__noreturn__)) |
856 | #endif |
877 | #endif |
857 | |
878 | |
858 | #if ECB_GCC_VERSION(4,3) |
879 | #if ECB_GCC_VERSION(4,3) |
… | |
… | |
1065 | /* but less than using pointers, and always seems to */ |
1086 | /* but less than using pointers, and always seems to */ |
1066 | /* successfully return a constant. */ |
1087 | /* successfully return a constant. */ |
1067 | /* the reason why we have this horrible preprocessor mess */ |
1088 | /* the reason why we have this horrible preprocessor mess */ |
1068 | /* is to avoid it in all cases, at least on common architectures */ |
1089 | /* is to avoid it in all cases, at least on common architectures */ |
1069 | /* or when using a recent enough gcc version (>= 4.6) */ |
1090 | /* or when using a recent enough gcc version (>= 4.6) */ |
1070 | #if __i386 || __i386__ || _M_X86 || __amd64 || __amd64__ || _M_X64 |
1091 | #if ((__i386 || __i386__) && !__VOS__) || _M_IX86 || ECB_GCC_AMD64 || ECB_MSVC_AMD64 |
1071 | return 0x44; |
1092 | return 0x44; |
1072 | #elif __BYTE_ORDER__ && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ |
1093 | #elif __BYTE_ORDER__ && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ |
1073 | return 0x44; |
1094 | return 0x44; |
1074 | #elif __BYTE_ORDER__ && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ |
1095 | #elif __BYTE_ORDER__ && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ |
1075 | return 0x11; |
1096 | return 0x11; |
… | |
… | |
1126 | |
1147 | |
1127 | /* basically, everything uses "ieee pure-endian" floating point numbers */ |
1148 | /* basically, everything uses "ieee pure-endian" floating point numbers */ |
1128 | /* the only noteworthy exception is ancient armle, which uses order 43218765 */ |
1149 | /* the only noteworthy exception is ancient armle, which uses order 43218765 */ |
1129 | #if 0 \ |
1150 | #if 0 \ |
1130 | || __i386 || __i386__ \ |
1151 | || __i386 || __i386__ \ |
1131 | || __amd64 || __amd64__ || __x86_64 || __x86_64__ \ |
1152 | || ECB_GCC_AMD64 \ |
1132 | || __powerpc__ || __ppc__ || __powerpc64__ || __ppc64__ \ |
1153 | || __powerpc__ || __ppc__ || __powerpc64__ || __ppc64__ \ |
1133 | || defined __s390__ || defined __s390x__ \ |
1154 | || defined __s390__ || defined __s390x__ \ |
1134 | || defined __mips__ \ |
1155 | || defined __mips__ \ |
1135 | || defined __alpha__ \ |
1156 | || defined __alpha__ \ |
1136 | || defined __hppa__ \ |
1157 | || defined __hppa__ \ |
1137 | || defined __ia64__ \ |
1158 | || defined __ia64__ \ |
1138 | || defined __m68k__ \ |
1159 | || defined __m68k__ \ |
1139 | || defined __m88k__ \ |
1160 | || defined __m88k__ \ |
1140 | || defined __sh__ \ |
1161 | || defined __sh__ \ |
1141 | || defined _M_IX86 || defined _M_AMD64 || defined _M_IA64 \ |
1162 | || defined _M_IX86 || defined ECB_MSVC_AMD64 || defined _M_IA64 \ |
1142 | || (defined __arm__ && (defined __ARM_EABI__ || defined __EABI__ || defined __VFP_FP__ || defined _WIN32_WCE || defined __ANDROID__)) \ |
1163 | || (defined __arm__ && (defined __ARM_EABI__ || defined __EABI__ || defined __VFP_FP__ || defined _WIN32_WCE || defined __ANDROID__)) \ |
1143 | || defined __aarch64__ |
1164 | || defined __aarch64__ |
1144 | #define ECB_STDFP 1 |
1165 | #define ECB_STDFP 1 |
1145 | #include <string.h> /* for memcpy */ |
1166 | #include <string.h> /* for memcpy */ |
1146 | #else |
1167 | #else |
… | |
… | |
1165 | #endif |
1186 | #endif |
1166 | |
1187 | |
1167 | #if ECB_C99 || _XOPEN_VERSION >= 600 || _POSIX_VERSION >= 200112L |
1188 | #if ECB_C99 || _XOPEN_VERSION >= 600 || _POSIX_VERSION >= 200112L |
1168 | #define ecb_ldexpf(x,e) ldexpf ((x), (e)) |
1189 | #define ecb_ldexpf(x,e) ldexpf ((x), (e)) |
1169 | #else |
1190 | #else |
1170 | #define ecb_ldexpf(x,e) (float) ldexp ((x), (e)) |
1191 | #define ecb_ldexpf(x,e) (float) ldexp ((float) (x), (e)) |
1171 | #endif |
1192 | #endif |
1172 | |
1193 | |
1173 | /* converts an ieee half/binary16 to a float */ |
1194 | /* converts an ieee half/binary16 to a float */ |
1174 | ecb_function_ ecb_const float ecb_binary16_to_float (uint16_t x); |
1195 | ecb_function_ ecb_const float ecb_binary16_to_float (uint16_t x); |
1175 | ecb_function_ ecb_const float |
1196 | ecb_function_ ecb_const float |