… | |
… | |
53 | C<uint32_t>, then the corresponding function works only with that type. If |
53 | C<uint32_t>, then the corresponding function works only with that type. If |
54 | only a generic name is used (C<expr>, C<cond>, C<value> and so on), then |
54 | only a generic name is used (C<expr>, C<cond>, C<value> and so on), then |
55 | the corresponding function relies on C to implement the correct types, and |
55 | the corresponding function relies on C to implement the correct types, and |
56 | is usually implemented as a macro. Specifically, a "bool" in this manual |
56 | is usually implemented as a macro. Specifically, a "bool" in this manual |
57 | refers to any kind of boolean value, not a specific type. |
57 | refers to any kind of boolean value, not a specific type. |
|
|
58 | |
|
|
59 | =head2 TYPES / TYPE SUPPORT |
|
|
60 | |
|
|
61 | ecb.h makes sure that the following types are defined (in the expected way): |
|
|
62 | |
|
|
63 | int8_t uint8_t int16_t uint16_t |
|
|
64 | int32_t uint32_t int64_t uint64_t |
|
|
65 | intptr_t uintptr_t |
|
|
66 | |
|
|
67 | The macro C<ECB_PTRSIZE> is defined to the size of a pointer on this |
|
|
68 | platform (currently C<4> or C<8>). |
58 | |
69 | |
59 | =head2 GCC ATTRIBUTES |
70 | =head2 GCC ATTRIBUTES |
60 | |
71 | |
61 | A major part of libecb deals with GCC attributes. These are additional |
72 | A major part of libecb deals with GCC attributes. These are additional |
62 | attributes that you can assign to functions, variables and sometimes even |
73 | attributes that you can assign to functions, variables and sometimes even |
… | |
… | |
455 | For example: |
466 | For example: |
456 | |
467 | |
457 | ecb_popcount32 (7) = 3 |
468 | ecb_popcount32 (7) = 3 |
458 | ecb_popcount32 (255) = 8 |
469 | ecb_popcount32 (255) = 8 |
459 | |
470 | |
|
|
471 | =item uint8_t ecb_bitrev8 (uint8_t x) |
|
|
472 | |
|
|
473 | =item uint16_t ecb_bitrev16 (uint16_t x) |
|
|
474 | |
|
|
475 | =item uint32_t ecb_bitrev32 (uint32_t x) |
|
|
476 | |
|
|
477 | Reverses the bits in x, i.e. the MSB becomes the LSB, MSB-1 becomes LSB+1 |
|
|
478 | and so on. |
|
|
479 | |
|
|
480 | Example: |
|
|
481 | |
|
|
482 | ecb_bitrev8 (0xa7) = 0xea |
|
|
483 | ecb_bitrev32 (0xffcc4411) = 0x882233ff |
|
|
484 | |
460 | =item uint32_t ecb_bswap16 (uint32_t x) |
485 | =item uint32_t ecb_bswap16 (uint32_t x) |
461 | |
486 | |
462 | =item uint32_t ecb_bswap32 (uint32_t x) |
487 | =item uint32_t ecb_bswap32 (uint32_t x) |
463 | |
488 | |
464 | =item uint64_t ecb_bswap64 (uint64_t x) |
489 | =item uint64_t ecb_bswap64 (uint64_t x) |
… | |
… | |
527 | |
552 | |
528 | =item x = ecb_div_ru (val, div) |
553 | =item x = ecb_div_ru (val, div) |
529 | |
554 | |
530 | Returns C<val> divided by C<div> rounded down or up, respectively. |
555 | Returns C<val> divided by C<div> rounded down or up, respectively. |
531 | C<val> and C<div> must have integer types and C<div> must be strictly |
556 | C<val> and C<div> must have integer types and C<div> must be strictly |
532 | positive. |
557 | positive. Note that these functions are implemented with macros in C |
|
|
558 | and with function templates in C++. |
533 | |
559 | |
534 | =back |
560 | =back |
535 | |
561 | |
536 | =head2 UTILITY |
562 | =head2 UTILITY |
537 | |
563 | |