#if !defined HAVE_BITBLOCK_H__
#define      HAVE_BITBLOCK_H__

#include "fxttypes.h"
#include "bits/bitsperlong.h"


static inline ulong bit_block(ulong p, ulong n)
// Return word with length-n bit block starting at bit p set.
// Both p and n are effectively taken modulo BITS_PER_LONG.
{
    ulong x = (1UL<<n) - 1;
    return  x << p;
}
// -------------------------

static inline ulong cyclic_bit_block(ulong p, ulong n)
// Return word with length-n bit block starting at bit p set.
// The result is possibly wrapped around the word boundary.
// Both p and n are effectively taken modulo BITS_PER_LONG.
{
    ulong x = (1UL<<n) - 1;
    return  (x<<p) | (x>>(BITS_PER_LONG-p));
}
// -------------------------



#endif  // !defined HAVE_BITBLOCK_H__
