This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| en:software:homelab:library:bit [2010/03/08 10:39] – mikk.leini | en:software:homelab:library:bit [2020/07/20 09:00] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== Bitwise | + | ====== Bitwise |
| - | Bitwise operations library contains a set of macro functions to do common bit manipulation operations. They are used by the rest of the library and they can be used everythere | + | Bitwise operations library contains a set of macro functions to do common bit manipulation operations. They are used by the rest of the library and can be used everywhere |
| - | Bit index is used to specify the bit in the binary number. Indexes are counted from zero, where zero represents the least significant bit (LSB). For example, 8-bit number | + | Bit index is used to specify the bit in the binary number. Indexes are counted from zero, where zero represents the least significant bit (LSB). For example, |
| - | ===== Funktsioonid | + | ===== Functions |
| * **// | * **// | ||
| Line 60: | Line 60: | ||
| } | } | ||
| </ | </ | ||
| + | |||
| + | ===== Source ===== | ||
| + | |||
| + | The following is a shortened version of the bitwise operations library source code. | ||
| + | |||
| + | <code c> | ||
| + | // | ||
| + | // Functions for handling bits. | ||
| + | // | ||
| + | #define bit_mask(bit) | ||
| + | #define bit_set(value, | ||
| + | #define bit_clear(value, | ||
| + | #define bit_invert(value, | ||
| + | #define bit_is_set(value, | ||
| + | #define bit_is_clear(value, | ||
| + | #define bit_set_to(v, | ||
| + | |||
| + | // | ||
| + | // Functions for handling bit masks. | ||
| + | // | ||
| + | #define bitmask_set(value, | ||
| + | #define bitmask_clear(value, | ||
| + | #define bitmask_invert(value, | ||
| + | #define bitmask_set_to(v, | ||
| + | #define bitmask_is_set(value, | ||
| + | </ | ||
| + | |||