--- libecb/ecb.pod 2011/08/25 16:06:08 1.38 +++ libecb/ecb.pod 2012/05/29 14:35:43 1.45 @@ -56,6 +56,66 @@ is usually implemented as a macro. Specifically, a "bool" in this manual refers to any kind of boolean value, not a specific type. +=head2 TYPES / TYPE SUPPORT + +ecb.h makes sure that the following types are defined (in the expected way): + + int8_t uint8_t int16_t uint16_t + int32_t uint32_t int64_t uint64_t + intptr_t uintptr_t ptrdiff_t + +The macro C is defined to the size of a pointer on this +platform (currently C<4> or C<8>) and can be used in preprocessor +expressions. + +=head2 LANGUAGE/COMPILER VERSIONS + +All the following symbols expand to an expressionb that cna be tested in +preprocessor instructions as well as treated as a boolean (use C to +ensure it's either C<0> or C<1> if you need that). + +=over 4 + +=item ECB_C + +True if the implementation defines the C<__STDC__> macro to a true value, +which is typically true for both C and C++ compilers. + +=item ECB_C99 + +True if the implementation claims to be C99 compliant. + +=item ECB_C11 + +True if the implementation claims to be C11 compliant. + +=item ECB_CPP + +True if the implementation defines the C<__cplusplus__> macro to a true +value, which is typically true for C++ compilers. + +=item ECB_CPP98 + +True if the implementation claims to be compliant to ISO/IEC 14882:1998 +(the first C++ ISO standard) or any later vwersion. Typically true for all +C++ compilers. + +=item ECB_CPP11 + +True if the implementation claims to be compliant to ISO/IEC 14882:2011 +(C++11) or any later vwersion. + +=item ECB_GCC_VERSION(major,minor) + +Expands to a true value (suitable for testing in by the preprocessor) +if the compiler used is GNU C and the version is the givne version, or +higher. + +This macro tries to return false on compilers that claim to be GCC +compatible but aren't. + +=back + =head2 GCC ATTRIBUTES A major part of libecb deals with GCC attributes. These are additional @@ -427,6 +487,14 @@ ecb_ctz32 (3) = 0 ecb_ctz32 (6) = 1 +=item bool ecb_is_pot32 (uint32_t x) + +=item bool ecb_is_pot64 (uint32_t x) + +Return true iff C is a power of two or C. + +For smaller types then C you can safely use C. + =item int ecb_ld32 (uint32_t x) =item int ecb_ld64 (uint64_t x) @@ -457,6 +525,20 @@ ecb_popcount32 (7) = 3 ecb_popcount32 (255) = 8 +=item uint8_t ecb_bitrev8 (uint8_t x) + +=item uint16_t ecb_bitrev16 (uint16_t x) + +=item uint32_t ecb_bitrev32 (uint32_t x) + +Reverses the bits in x, i.e. the MSB becomes the LSB, MSB-1 becomes LSB+1 +and so on. + +Example: + + ecb_bitrev8 (0xa7) = 0xea + ecb_bitrev32 (0xffcc4411) = 0x882233ff + =item uint32_t ecb_bswap16 (uint32_t x) =item uint32_t ecb_bswap32 (uint32_t x) @@ -550,4 +632,28 @@ =back +=head2 SYMBOLS GOVERNING COMPILATION OF ECB.H ITSELF + +These symbols need to be defined before including F the first time. + +=over 4 + +=item ECB_NO_THRADS + +If F is never used from multiple threads, then this symbol can +be defined, in which case memory fences (and similar constructs) are +completely removed, leading to more efficient code and fewer dependencies. + +Setting this symbol to a true value implies C. + +=item ECB_NO_SMP + +The weaker version of C - if F is used from +multiple threads, but never concurrently (e.g. if the system the program +runs on has only a single CPU with a single core, no hyperthreading and so +on), then this symbol can be defined, leading to more efficient code and +fewer dependencies. + +=back +