Changeset e4f8c77 in mainline for uspace/lib/c/include/bitops.h


Ignore:
Timestamp:
2011-07-13T22:39:18Z (13 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
e6910c8
Parents:
5974661 (diff), 8ecef91 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge libposix.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/include/bitops.h

    r5974661 re4f8c77  
    3838#include <sys/types.h>
    3939
     40/** Mask with bit @a n set. */
     41#define BIT_V(type, n) \
     42    ((type)1 << ((n) - 1))
     43
     44/** Mask with rightmost @a n bits set. */
     45#define BIT_RRANGE(type, n) \
     46    (BIT_V(type, (n) + 1) - 1)
     47
     48/** Mask with bits @a hi .. @a lo set. @a hi >= @a lo. */
     49#define BIT_RANGE(type, hi, lo) \
     50    (BIT_RRANGE(type, (hi) - (lo) + 1) << (lo))
     51
     52/** Extract range of bits @a hi .. @a lo from @a value. */
     53#define BIT_RANGE_EXTRACT(type, hi, lo, value) \
     54    (((value) >> (lo)) & BIT_RRANGE(type, (hi) - (lo) + 1))
    4055
    4156/** Return position of first non-zero bit from left (i.e. [log_2(arg)]).
Note: See TracChangeset for help on using the changeset viewer.