… | |
… | |
85 | =over 4 |
85 | =over 4 |
86 | |
86 | |
87 | =item ECB_C |
87 | =item ECB_C |
88 | |
88 | |
89 | True if the implementation defines the C<__STDC__> macro to a true value, |
89 | True if the implementation defines the C<__STDC__> macro to a true value, |
90 | while not claiming to be C++. |
90 | while not claiming to be C++, i..e C, but not C++. |
91 | |
91 | |
92 | =item ECB_C99 |
92 | =item ECB_C99 |
93 | |
93 | |
94 | True if the implementation claims to be compliant to C99 (ISO/IEC |
94 | True if the implementation claims to be compliant to C99 (ISO/IEC |
95 | 9899:1999) or any later version, while not claiming to be C++. |
95 | 9899:1999) or any later version, while not claiming to be C++. |
… | |
… | |
110 | =item ECB_CPP11, ECB_CPP14, ECB_CPP17 |
110 | =item ECB_CPP11, ECB_CPP14, ECB_CPP17 |
111 | |
111 | |
112 | True if the implementation claims to be compliant to C++11/C++14/C++17 |
112 | True if the implementation claims to be compliant to C++11/C++14/C++17 |
113 | (ISO/IEC 14882:2011, :2014, :2017) or any later version. |
113 | (ISO/IEC 14882:2011, :2014, :2017) or any later version. |
114 | |
114 | |
|
|
115 | Note that many C++20 features will likely have their own feature test |
|
|
116 | macros (see e.g. L<http://eel.is/c++draft/cpp.predefined#1.8>). |
|
|
117 | |
|
|
118 | =item ECB_OPTIMIZE_SIZE |
|
|
119 | |
|
|
120 | Is C<1> when the compiler optimizes for size, C<0> otherwise. This symbol |
|
|
121 | can also be defined before including F<ecb.h>, in which case it will be |
|
|
122 | unchanged. |
|
|
123 | |
115 | =item ECB_GCC_VERSION (major, minor) |
124 | =item ECB_GCC_VERSION (major, minor) |
116 | |
125 | |
117 | Expands to a true value (suitable for testing in by the preprocessor) |
126 | Expands to a true value (suitable for testing by the preprocessor) if the |
118 | if the compiler used is GNU C and the version is the given version, or |
127 | compiler used is GNU C and the version is the given version, or higher. |
119 | higher. |
|
|
120 | |
128 | |
121 | This macro tries to return false on compilers that claim to be GCC |
129 | This macro tries to return false on compilers that claim to be GCC |
122 | compatible but aren't. |
130 | compatible but aren't. |
123 | |
131 | |
124 | =item ECB_EXTERN_C |
132 | =item ECB_EXTERN_C |
… | |
… | |
143 | |
151 | |
144 | ECB_EXTERN_C_END |
152 | ECB_EXTERN_C_END |
145 | |
153 | |
146 | =item ECB_STDFP |
154 | =item ECB_STDFP |
147 | |
155 | |
148 | If this evaluates to a true value (suitable for testing in by the |
156 | If this evaluates to a true value (suitable for testing by the |
149 | preprocessor), then C<float> and C<double> use IEEE 754 single/binary32 |
157 | preprocessor), then C<float> and C<double> use IEEE 754 single/binary32 |
150 | and double/binary64 representations internally I<and> the endianness of |
158 | and double/binary64 representations internally I<and> the endianness of |
151 | both types match the endianness of C<uint32_t> and C<uint64_t>. |
159 | both types match the endianness of C<uint32_t> and C<uint64_t>. |
152 | |
160 | |
153 | This means you can just copy the bits of a C<float> (or C<double>) to an |
161 | This means you can just copy the bits of a C<float> (or C<double>) to an |
… | |
… | |
408 | |
416 | |
409 | =head2 OPTIMISATION HINTS |
417 | =head2 OPTIMISATION HINTS |
410 | |
418 | |
411 | =over 4 |
419 | =over 4 |
412 | |
420 | |
413 | =item ECB_OPTIMIZE_SIZE |
|
|
414 | |
|
|
415 | Is C<1> when the compiler optimizes for size, C<0> otherwise. This symbol |
|
|
416 | can also be defined before including F<ecb.h>, in which case it will be |
|
|
417 | unchanged. |
|
|
418 | |
|
|
419 | =item bool ecb_is_constant (expr) |
421 | =item bool ecb_is_constant (expr) |
420 | |
422 | |
421 | Returns true iff the expression can be deduced to be a compile-time |
423 | Returns true iff the expression can be deduced to be a compile-time |
422 | constant, and false otherwise. |
424 | constant, and false otherwise. |
423 | |
425 | |
… | |
… | |
694 | |
696 | |
695 | =item uint32_t ecb_bswap32 (uint32_t x) |
697 | =item uint32_t ecb_bswap32 (uint32_t x) |
696 | |
698 | |
697 | =item uint64_t ecb_bswap64 (uint64_t x) |
699 | =item uint64_t ecb_bswap64 (uint64_t x) |
698 | |
700 | |
|
|
701 | =item T ecb_bswap (T x) |
|
|
702 | |
699 | These functions return the value of the 16-bit (32-bit, 64-bit) value |
703 | These functions return the value of the 16-bit (32-bit, 64-bit) value |
700 | C<x> after reversing the order of bytes (0x11223344 becomes 0x44332211 in |
704 | C<x> after reversing the order of bytes (0x11223344 becomes 0x44332211 in |
701 | C<ecb_bswap32>). |
705 | C<ecb_bswap32>). |
702 | |
706 | |
703 | The overloaded C++ C<ecb_bswap> function supports C<uint8_t>, C<uint16_t>, |
707 | The overloaded C++ C<ecb_bswap> function supports C<uint8_t>, C<uint16_t>, |
… | |
… | |
754 | =item uint_fast64_t ecb_le_u64_to_host (uint_fast64_t v) |
758 | =item uint_fast64_t ecb_le_u64_to_host (uint_fast64_t v) |
755 | |
759 | |
756 | Convert an unsigned 16, 32 or 64 bit value from big or little endian to host byte order. |
760 | Convert an unsigned 16, 32 or 64 bit value from big or little endian to host byte order. |
757 | |
761 | |
758 | The naming convention is C<ecb_>(C<be>|C<le>)C<_u>C<16|32|64>C<_to_host>, |
762 | The naming convention is C<ecb_>(C<be>|C<le>)C<_u>C<16|32|64>C<_to_host>, |
759 | where be and le stand for big endian and little endian, respectively. |
763 | where C<be> and C<le> stand for big endian and little endian, respectively. |
760 | |
764 | |
761 | =item uint_fast16_t ecb_host_to_be_u16 (uint_fast16_t v) |
765 | =item uint_fast16_t ecb_host_to_be_u16 (uint_fast16_t v) |
762 | |
766 | |
763 | =item uint_fast32_t ecb_host_to_be_u32 (uint_fast32_t v) |
767 | =item uint_fast32_t ecb_host_to_be_u32 (uint_fast32_t v) |
764 | |
768 | |
… | |
… | |
852 | |
856 | |
853 | In C++ the following additional template functions are supported: |
857 | In C++ the following additional template functions are supported: |
854 | |
858 | |
855 | =over 4 |
859 | =over 4 |
856 | |
860 | |
857 | =item T ecb_peek (const void *ptr) |
861 | =item T ecb_peek<T> (const void *ptr) |
858 | |
862 | |
859 | =item T ecb_peek_be (const void *ptr) |
863 | =item T ecb_peek_be<T> (const void *ptr) |
860 | |
864 | |
861 | =item T ecb_peek_le (const void *ptr) |
865 | =item T ecb_peek_le<T> (const void *ptr) |
862 | |
866 | |
863 | =item T ecb_peek_u (const void *ptr) |
867 | =item T ecb_peek_u<T> (const void *ptr) |
864 | |
868 | |
865 | =item T ecb_peek_be_u (const void *ptr) |
869 | =item T ecb_peek_be_u<T> (const void *ptr) |
866 | |
870 | |
867 | =item T ecb_peek_le_u (const void *ptr) |
871 | =item T ecb_peek_le_u<T> (const void *ptr) |
868 | |
872 | |
869 | Similarly to their C counterparts, these functions load an unsigned 8, 16, |
873 | Similarly to their C counterparts, these functions load an unsigned 8, 16, |
870 | 32 or 64 bit value from memory, with optional conversion from big/little |
874 | 32 or 64 bit value from memory, with optional conversion from big/little |
871 | endian. |
875 | endian. |
872 | |
876 | |
873 | Since the type cannot be deduced, it has top be specified explicitly, e.g. |
877 | Since the type cannot be deduced, it has to be specified explicitly, e.g. |
874 | |
878 | |
875 | uint_fast16_t v = ecb_peek<uint16_t> (ptr); |
879 | uint_fast16_t v = ecb_peek<uint16_t> (ptr); |
876 | |
880 | |
877 | C<T> must be one of C<uint8_t>, C<uint16_t>, C<uint32_t> or C<uint64_t>. |
881 | C<T> must be one of C<uint8_t>, C<uint16_t>, C<uint32_t> or C<uint64_t>. |
878 | |
882 | |