… | |
… | |
80 | |
80 | |
81 | All the following symbols expand to an expression that can be tested in |
81 | All the following symbols expand to an expression that can be tested in |
82 | preprocessor instructions as well as treated as a boolean (use C<!!> to |
82 | preprocessor instructions as well as treated as a boolean (use C<!!> to |
83 | ensure it's either C<0> or C<1> if you need that). |
83 | ensure it's either C<0> or C<1> if you need that). |
84 | |
84 | |
85 | =over 4 |
85 | =over |
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++, i..e C, but not C++. |
90 | while not claiming to be C++, i..e C, but not C++. |
… | |
… | |
187 | |
187 | |
188 | =back |
188 | =back |
189 | |
189 | |
190 | =head2 MACRO TRICKERY |
190 | =head2 MACRO TRICKERY |
191 | |
191 | |
192 | =over 4 |
192 | =over |
193 | |
193 | |
194 | =item ECB_CONCAT (a, b) |
194 | =item ECB_CONCAT (a, b) |
195 | |
195 | |
196 | Expands any macros in C<a> and C<b>, then concatenates the result to form |
196 | Expands any macros in C<a> and C<b>, then concatenates the result to form |
197 | a single token. This is mainly useful to form identifiers from components, |
197 | a single token. This is mainly useful to form identifiers from components, |
… | |
… | |
238 | declarations must be put before the whole declaration: |
238 | declarations must be put before the whole declaration: |
239 | |
239 | |
240 | ecb_const int mysqrt (int a); |
240 | ecb_const int mysqrt (int a); |
241 | ecb_unused int i; |
241 | ecb_unused int i; |
242 | |
242 | |
243 | =over 4 |
243 | =over |
244 | |
244 | |
245 | =item ecb_unused |
245 | =item ecb_unused |
246 | |
246 | |
247 | Marks a function or a variable as "unused", which simply suppresses a |
247 | Marks a function or a variable as "unused", which simply suppresses a |
248 | warning by the compiler when it detects it as unused. This is useful when |
248 | warning by the compiler when it detects it as unused. This is useful when |
… | |
… | |
422 | |
422 | |
423 | =back |
423 | =back |
424 | |
424 | |
425 | =head2 OPTIMISATION HINTS |
425 | =head2 OPTIMISATION HINTS |
426 | |
426 | |
427 | =over 4 |
427 | =over |
428 | |
428 | |
429 | =item bool ecb_is_constant (expr) |
429 | =item bool ecb_is_constant (expr) |
430 | |
430 | |
431 | Returns true iff the expression can be deduced to be a compile-time |
431 | Returns true iff the expression can be deduced to be a compile-time |
432 | constant, and false otherwise. |
432 | constant, and false otherwise. |
… | |
… | |
589 | |
589 | |
590 | =back |
590 | =back |
591 | |
591 | |
592 | =head2 BIT FIDDLING / BIT WIZARDRY |
592 | =head2 BIT FIDDLING / BIT WIZARDRY |
593 | |
593 | |
594 | =over 4 |
594 | =over |
595 | |
595 | |
596 | =item bool ecb_big_endian () |
596 | =item bool ecb_big_endian () |
597 | |
597 | |
598 | =item bool ecb_little_endian () |
598 | =item bool ecb_little_endian () |
599 | |
599 | |
… | |
… | |
749 | |
749 | |
750 | =back |
750 | =back |
751 | |
751 | |
752 | =head2 HOST ENDIANNESS CONVERSION |
752 | =head2 HOST ENDIANNESS CONVERSION |
753 | |
753 | |
754 | =over 4 |
754 | =over |
755 | |
755 | |
756 | =item uint_fast16_t ecb_be_u16_to_host (uint_fast16_t v) |
756 | =item uint_fast16_t ecb_be_u16_to_host (uint_fast16_t v) |
757 | |
757 | |
758 | =item uint_fast32_t ecb_be_u32_to_host (uint_fast32_t v) |
758 | =item uint_fast32_t ecb_be_u32_to_host (uint_fast32_t v) |
759 | |
759 | |
… | |
… | |
787 | |
787 | |
788 | =back |
788 | =back |
789 | |
789 | |
790 | In C++ the following additional template functions are supported: |
790 | In C++ the following additional template functions are supported: |
791 | |
791 | |
792 | =over 4 |
792 | =over |
793 | |
793 | |
794 | =item T ecb_be_to_host (T v) |
794 | =item T ecb_be_to_host (T v) |
795 | |
795 | |
796 | =item T ecb_le_to_host (T v) |
796 | =item T ecb_le_to_host (T v) |
797 | |
797 | |
… | |
… | |
810 | |
810 | |
811 | =head2 UNALIGNED LOAD/STORE |
811 | =head2 UNALIGNED LOAD/STORE |
812 | |
812 | |
813 | These function load or store unaligned multi-byte values. |
813 | These function load or store unaligned multi-byte values. |
814 | |
814 | |
815 | =over 4 |
815 | =over |
816 | |
816 | |
817 | =item uint_fast16_t ecb_peek_u16_u (const void *ptr) |
817 | =item uint_fast16_t ecb_peek_u16_u (const void *ptr) |
818 | |
818 | |
819 | =item uint_fast32_t ecb_peek_u32_u (const void *ptr) |
819 | =item uint_fast32_t ecb_peek_u32_u (const void *ptr) |
820 | |
820 | |
… | |
… | |
864 | |
864 | |
865 | =back |
865 | =back |
866 | |
866 | |
867 | In C++ the following additional template functions are supported: |
867 | In C++ the following additional template functions are supported: |
868 | |
868 | |
869 | =over 4 |
869 | =over |
870 | |
870 | |
871 | =item T ecb_peek<T> (const void *ptr) |
871 | =item T ecb_peek<T> (const void *ptr) |
872 | |
872 | |
873 | =item T ecb_peek_be<T> (const void *ptr) |
873 | =item T ecb_peek_be<T> (const void *ptr) |
874 | |
874 | |
… | |
… | |
918 | |
918 | |
919 | =back |
919 | =back |
920 | |
920 | |
921 | =head2 FLOATING POINT FIDDLING |
921 | =head2 FLOATING POINT FIDDLING |
922 | |
922 | |
923 | =over 4 |
923 | =over |
924 | |
924 | |
925 | =item ECB_INFINITY [-UECB_NO_LIBM] |
925 | =item ECB_INFINITY [-UECB_NO_LIBM] |
926 | |
926 | |
927 | Evaluates to positive infinity if supported by the platform, otherwise to |
927 | Evaluates to positive infinity if supported by the platform, otherwise to |
928 | a truly huge number. |
928 | a truly huge number. |
… | |
… | |
1006 | |
1006 | |
1007 | =back |
1007 | =back |
1008 | |
1008 | |
1009 | =head2 ARITHMETIC |
1009 | =head2 ARITHMETIC |
1010 | |
1010 | |
1011 | =over 4 |
1011 | =over |
1012 | |
1012 | |
1013 | =item x = ecb_mod (m, n) |
1013 | =item x = ecb_mod (m, n) |
1014 | |
1014 | |
1015 | Returns C<m> modulo C<n>, which is the same as the positive remainder |
1015 | Returns C<m> modulo C<n>, which is the same as the positive remainder |
1016 | of the division operation between C<m> and C<n>, using floored |
1016 | of the division operation between C<m> and C<n>, using floored |
… | |
… | |
1047 | |
1047 | |
1048 | =back |
1048 | =back |
1049 | |
1049 | |
1050 | =head2 UTILITY |
1050 | =head2 UTILITY |
1051 | |
1051 | |
1052 | =over 4 |
1052 | =over |
1053 | |
1053 | |
1054 | =item element_count = ecb_array_length (name) |
1054 | =item element_count = ecb_array_length (name) |
1055 | |
1055 | |
1056 | Returns the number of elements in the array C<name>. For example: |
1056 | Returns the number of elements in the array C<name>. For example: |
1057 | |
1057 | |
… | |
… | |
1065 | |
1065 | |
1066 | =head2 SYMBOLS GOVERNING COMPILATION OF ECB.H ITSELF |
1066 | =head2 SYMBOLS GOVERNING COMPILATION OF ECB.H ITSELF |
1067 | |
1067 | |
1068 | These symbols need to be defined before including F<ecb.h> the first time. |
1068 | These symbols need to be defined before including F<ecb.h> the first time. |
1069 | |
1069 | |
1070 | =over 4 |
1070 | =over |
1071 | |
1071 | |
1072 | =item ECB_NO_THREADS |
1072 | =item ECB_NO_THREADS |
1073 | |
1073 | |
1074 | If F<ecb.h> is never used from multiple threads, then this symbol can |
1074 | If F<ecb.h> is never used from multiple threads, then this symbol can |
1075 | be defined, in which case memory fences (and similar constructs) are |
1075 | be defined, in which case memory fences (and similar constructs) are |