bit twiddling

From: Andrew Morton (andrewm@uow.edu.au)
Date: Wed May 24 2000 - 07:01:44 EST


It appears that the sparc64 compiler reverses the packing order of
bitfields. So if you are relying on C bitfield ordering to map onto
hardware bits (or anything else), stop it or you'll go blind.

Also, is there a repository of bit-stuffing macros anywhere in the
kernel tree? Things like:

#define BFEXT(value, offset, bitcount) \
    ((((unsigned long)(value)) >> (offset)) & ((1 << (bitcount)) - 1))

#define BFINS(lhs, rhs, offset, bitcount) \
    (((lhs) & ~(((1 << (bitcount)) - 1)) << (offset)) | \
        (((rhs) & ((1 << (bitcount)) - 1)) << (offset)))

They were fun to write, but surely this wheel has been invented?

-- 
-akpm-

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Wed May 31 2000 - 21:00:11 EST