Commit 20448060 authored by Etienne Renault's avatar Etienne Renault
Browse files

bricks: update and move to c++14

* Makefile.am, bricks/brick-assert,
bricks/brick-assert.h, spot/ltsmin/ltsmin.cc,
spot/mc/ec.hh: here.

* bricks/brick-bitlevel.h, bricks/brick-hash.h,
bricks/brick-hashset.h, bricks/brick-shmem.h,
bricks/brick-types.h: Rename as ...
* bricks/brick-bitlevel, bricks/brick-hash,
bricks/brick-hashset, bricks/brick-shmem,
bricks/brick-types: ... these
parent 92a14c5a
......@@ -39,9 +39,9 @@ SUBDIRS = picosat buddy lib ltdl spot bin tests $(PYTHON_SUBDIR) $(DOC_SUBDIR) \
UTF8 = utf8/README.md utf8/utf8.h \
utf8/utf8/checked.h utf8/utf8/core.h utf8/utf8/unchecked.h
nobase_include_HEADERS= bricks/brick-assert.h bricks/brick-bitlevel.h \
bricks/brick-hash.h bricks/brick-hashset.h bricks/brick-shmem.h \
bricks/brick-types.h
nobase_include_HEADERS= bricks/brick-assert bricks/brick-bitlevel \
bricks/brick-hash bricks/brick-hashset bricks/brick-shmem \
bricks/brick-types
DEBIAN = \
debian/changelog \
......
// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 4 -*-
/*
* Various assert macros based on C++ exceptions and their support code.
*/
/*
* (c) 2006-2016 Petr Ročkai <code@fixp.eu>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <exception>
#include <string>
#include <sstream>
#ifndef TEST
#define TEST(n) void n()
#define TEST_FAILING(n) void n()
#endif
#ifndef NDEBUG
#define BRICK_SHARP_FIRST(x, ...) #x
#define ASSERT(...) ::brick::_assert::assert_fn( \
BRICK_LOCWRAP( BRICK_LOCATION( BRICK_SHARP_FIRST( __VA_ARGS__, ignored ) ) ), __VA_ARGS__ )
#define ASSERT_PRED(p, x) ::brick::_assert::assert_pred_fn( \
BRICK_LOCWRAP( BRICK_LOCATION( #p "( " #x " )" ) ), x, p( x ) )
#define ASSERT_EQ(x, y) ::brick::_assert::assert_eq_fn( \
BRICK_LOCWRAP( BRICK_LOCATION( #x " == " #y ) ), x, y )
#define ASSERT_LT(x, y) ::brick::_assert::assert_lt_fn( \
BRICK_LOCWRAP( BRICK_LOCATION( #x " < " #y ) ), x, y )
#define ASSERT_LEQ(x, y) ::brick::_assert::assert_leq_fn( \
BRICK_LOCWRAP( BRICK_LOCATION( #x " <= " #y ) ), x, y )
#define ASSERT_NEQ(x, y) ::brick::_assert::assert_neq_fn( \
BRICK_LOCWRAP( BRICK_LOCATION( #x " != " #y ) ), x, y )
#define ASSERT_EQ_IDX(i, x, y) ::brick::_assert::assert_eq_fn( \
BRICK_LOCWRAP( BRICK_LOCATION_I( #x " == " #y, i ) ), x, y )
#else
#define ASSERT(...) static_cast< decltype(__VA_ARGS__, void(0)) >(0)
#define ASSERT_PRED(p, x) static_cast< decltype(p, x, void(0)) >(0)
#define ASSERT_EQ(x, y) static_cast< decltype(x, y, void(0)) >(0)
#define ASSERT_LEQ(x, y) static_cast< decltype(x, y, void(0)) >(0)
#define ASSERT_LT(x, y) static_cast< decltype(x, y, void(0)) >(0)
#define ASSERT_NEQ(x, y) static_cast< decltype(x, y, void(0)) >(0)
#define ASSERT_EQ_IDX(i, x, y) static_cast< decltype(i, x, y, void(0)) >(0)
#endif
/* you must #include <brick-string.h> to use ASSERT_UNREACHABLE_F */
#define UNREACHABLE_F(...) ::brick::_assert::assert_die_fn( \
BRICK_LOCWRAP( BRICK_LOCATION( brick::string::fmtf(__VA_ARGS__) ) ) )
#define UNREACHABLE(x) ::brick::_assert::assert_die_fn( \
BRICK_LOCWRAP( BRICK_LOCATION( x ) ) )
#define UNREACHABLE_() ::brick::_assert::assert_die_fn( \
BRICK_LOCWRAP( BRICK_LOCATION( "an unreachable location" ) ) )
#define NOT_IMPLEMENTED() ::brick::_assert::assert_die_fn( \
BRICK_LOCWRAP( BRICK_LOCATION( "a missing implementation" ) ) )
#ifdef _MSC_VER
#define UNUSED
#define noexcept
#else
#define UNUSED __attribute__((unused))
#endif
#ifndef BRICK_ASSERT_H
#define BRICK_ASSERT_H
namespace brick {
namespace _assert {
/* discard any number of parameters, taken as const references */
template< typename... X >
void unused( const X&... ) { }
struct Location {
int line, iteration;
std::string file, stmt;
Location( const char *f, int l, std::string st, int iter = -1 )
: line( l ), iteration( iter ), file( f ), stmt( st )
{
int slashes = 0;
for ( int i = 0; i < int( file.size() ); ++i )
if ( file[i] == '/' )
++ slashes;
while ( slashes >= 3 )
{
file = std::string( file, file.find( "/" ) + 1, std::string::npos );
-- slashes;
}
if ( f != file )
file = ".../" + file;
}
};
#define BRICK_LOCATION(stmt) ::brick::_assert::Location( __FILE__, __LINE__, stmt )
#define BRICK_LOCATION_I(stmt, i) ::brick::_assert::Location( __FILE__, __LINE__, stmt, i )
// lazy location construction in C++11
#if __cplusplus >= 201103L
#define BRICK_LOCWRAP(x) [&]{ return (x); }
#define BRICK_LOCUNWRAP(x) (x)()
#else
#define BRICK_LOCWRAP(x) (x)
#define BRICK_LOCUNWRAP(x) (x)
#endif
struct AssertFailed : std::exception
{
std::string str;
template< typename X >
friend inline AssertFailed &operator<<( AssertFailed &f, X x )
{
std::stringstream str;
str << x;
f.str += str.str();
return f;
}
AssertFailed( Location l, const char *expected = "expected" )
{
(*this) << l.file << ": " << l.line;
if ( l.iteration != -1 )
(*this) << " (iteration " << l.iteration << ")";
(*this) << ":\n " << expected << " " << l.stmt;
}
const char *what() const noexcept override { return str.c_str(); }
};
static inline void format( AssertFailed & ) {}
template< typename X, typename... Y >
void format( AssertFailed &f, X x, Y... y )
{
f << x;
format( f, y... );
}
template< typename Location, typename X, typename... Y >
void assert_fn( Location l, X x, Y... y )
{
if ( x )
return;
AssertFailed f( BRICK_LOCUNWRAP( l ) );
format( f, y... );
throw f;
}
template< typename Location >
inline void assert_die_fn( Location l ) __attribute__((noreturn));
template< typename Location >
inline void assert_die_fn( Location l )
{
throw AssertFailed( BRICK_LOCUNWRAP( l ), "encountered" );
}
#define ASSERT_FN(name, op, inv) \
template< typename Location > \
void assert_ ## name ## _fn( Location l, int64_t x, int64_t y ) \
{ \
if ( !( x op y ) ) { \
AssertFailed f( BRICK_LOCUNWRAP( l ) ); \
f << "\n but got " \
<< x << " " #inv " " << y << "\n"; \
throw f; \
} \
} \
\
template< typename Location, typename X, typename Y > \
auto assert_ ## name ## _fn( Location l, X x, Y y ) \
-> typename std::enable_if< \
!std::is_integral< X >::value || \
!std::is_integral< Y >::value >::type \
{ \
if ( !( x op y ) ) { \
AssertFailed f( BRICK_LOCUNWRAP( l ) ); \
f << "\n but got " \
<< x << " " #inv " " << y << "\n"; \
throw f; \
} \
}
ASSERT_FN(eq, ==, !=);
ASSERT_FN(leq, <=, >);
ASSERT_FN(lt, <, >=);
template< typename Location, typename X >
void assert_pred_fn( Location l, X x, bool p )
{
if ( !p ) {
AssertFailed f( BRICK_LOCUNWRAP( l ) );
f << "\n but got x = " << x << "\n";
throw f;
}
}
template< typename Location, typename X, typename Y >
void assert_neq_fn( Location l, X x, Y y )
{
if ( x != y )
return;
AssertFailed f( BRICK_LOCUNWRAP( l ) );
f << "\n but got "
<< x << " == " << y << "\n";
throw f;
}
}
}
#endif
// vim: syntax=cpp tabstop=4 shiftwidth=4 expandtab
// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 4 -*-
/*
* Various assert macros based on C++ exceptions and their support code.
*/
/*
* (c) 2006-2014 Petr Ročkai <me@mornfall.net>
*/
/* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. */
#include <exception>
#include <string>
#include <sstream>
#ifdef __divine__
#include <divine.h>
#endif
#ifndef TEST
#define TEST(n) void n()
#define TEST_FAILING(n) void n()
#endif
#ifdef __divine__
#define ASSERT(x) assert( x )
#define ASSERT_PRED(p, x) assert( p( x ) )
#define ASSERT_EQ(x, y) assert( (x) == (y) )
#define ASSERT_LEQ(x, y) assert( (x) <= (y) )
#define ASSERT_NEQ(x, y) assert ( (x) != (y) )
#define ASSERT_EQ_IDX(i, x, y) assert( (x) == (y) )
#elif !defined NDEBUG
#define ASSERT(x) ::brick::_assert::assert_fn( BRICK_LOCWRAP( BRICK_LOCATION( #x ) ), x )
#define ASSERT_PRED(p, x) ::brick::_assert::assert_pred_fn( BRICK_LOCWRAP( BRICK_LOCATION( #p "( " #x " )" ) ), x, p( x ) )
#define ASSERT_EQ(x, y) ::brick::_assert::assert_eq_fn( BRICK_LOCWRAP( BRICK_LOCATION( #x " == " #y ) ), x, y )
#define ASSERT_LEQ(x, y) ::brick::_assert::assert_leq_fn( BRICK_LOCWRAP( BRICK_LOCATION( #x " <= " #y ) ), x, y )
#define ASSERT_NEQ(x, y) ::brick::_assert::assert_neq_fn( BRICK_LOCWRAP( BRICK_LOCATION( #x " != " #y ) ), x, y )
#define ASSERT_EQ_IDX(i, x, y) ::brick::_assert::assert_eq_fn( BRICK_LOCWRAP( BRICK_LOCATION_I( #x " == " #y, i ) ), x, y )
#else
#define ASSERT(x) ((void)0)
#define ASSERT_PRED(p, x) ((void)0)
#define ASSERT_EQ(x, y) ((void)0)
#define ASSERT_LEQ(x, y) ((void)0)
#define ASSERT_NEQ(x, y) ((void)0)
#define ASSERT_EQ_IDX(i, x, y) ((void)0)
#endif
/* you must #include <brick-string.h> to use ASSERT_UNREACHABLE_F */
#define ASSERT_UNREACHABLE_F(...) ::brick::_assert::assert_die_fn( BRICK_LOCATION( brick::string::fmtf(__VA_ARGS__) ) )
#define ASSERT_UNREACHABLE(x) ::brick::_assert::assert_die_fn( BRICK_LOCATION( x ) )
#define ASSERT_UNIMPLEMENTED() ::brick::_assert::assert_die_fn( BRICK_LOCATION( "not imlemented" ) )
#ifdef _MSC_VER
#define UNUSED
#define noexcept
#else
#define UNUSED __attribute__((unused))
#endif
#ifndef BRICK_ASSERT_H
#define BRICK_ASSERT_H
namespace brick {
namespace _assert {
/* discard any number of paramentets, taken as const references */
template< typename... X >
void unused( const X&... ) { }
struct Location {
const char *file;
int line, iteration;
std::string stmt;
Location( const char *f, int l, std::string st, int iter = -1 )
: file( f ), line( l ), iteration( iter ), stmt( st ) {}
};
#define BRICK_LOCATION(stmt) ::brick::_assert::Location( __FILE__, __LINE__, stmt )
#define BRICK_LOCATION_I(stmt, i) ::brick::_assert::Location( __FILE__, __LINE__, stmt, i )
// lazy location construction in C++11
#if __cplusplus >= 201103L
#define BRICK_LOCWRAP(x) [&]{ return (x); }
#define BRICK_LOCUNWRAP(x) (x)()
#else
#define BRICK_LOCWRAP(x) (x)
#define BRICK_LOCUNWRAP(x) (x)
#endif
struct AssertFailed : std::exception {
std::string str;
template< typename X >
friend inline AssertFailed &operator<<( AssertFailed &f, X x )
{
std::stringstream str;
str << x;
f.str += str.str();
return f;
}
AssertFailed( Location l )
{
(*this) << l.file << ": " << l.line;
if ( l.iteration != -1 )
(*this) << " (iteration " << l.iteration << ")";
(*this) << ": assertion `" << l.stmt << "' failed;";
}
const char *what() const noexcept override { return str.c_str(); }
};
template< typename Location, typename X >
void assert_fn( Location l, X x )
{
if ( !x ) {
throw AssertFailed( BRICK_LOCUNWRAP( l ) );
}
}
inline void assert_die_fn( Location l ) __attribute__((noreturn));
inline void assert_die_fn( Location l )
{
throw AssertFailed( l );
}
template< typename Location, typename X, typename Y >
void assert_eq_fn( Location l, X x, Y y )
{
if ( !( x == y ) ) {
AssertFailed f( BRICK_LOCUNWRAP( l ) );
f << " got ["
<< x << "] != [" << y
<< "] instead";
throw f;
}
}
template< typename Location, typename X, typename Y >
void assert_leq_fn( Location l, X x, Y y )
{
if ( !( x <= y ) ) {
AssertFailed f( BRICK_LOCUNWRAP( l ) );
f << " got ["
<< x << "] > [" << y
<< "] instead";
throw f;
}
}
template< typename Location, typename X >
void assert_pred_fn( Location l, X x, bool p )
{
if ( !p ) {
AssertFailed f( BRICK_LOCUNWRAP( l ) );
f << " for " << x;
throw f;
}
}
template< typename Location, typename X, typename Y >
void assert_neq_fn( Location l, X x, Y y )
{
if ( x != y )
return;
AssertFailed f( BRICK_LOCUNWRAP( l ) );
f << " got ["
<< x << "] == [" << y << "] instead";
throw f;
}
}
}
#endif
// vim: syntax=cpp tabstop=4 shiftwidth=4 expandtab
......@@ -7,33 +7,25 @@
/*
* (c) 2013-2014 Jiří Weiser <xweiser1@fi.muni.cz>
* (c) 2013 Petr Ročkai <me@mornfall.net>
*/
/* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* (c) 2015 Vladimír Štill <xstill@fi.muni.cz>
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. */
#include <bricks/brick-assert.h>
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include "brick-assert"
#include <type_traits>
#include <limits>
#ifdef __linux
#include <asm/byteorder.h>
......@@ -43,10 +35,6 @@
#define LITTLE_ENDIAN 1234
#endif
#ifndef bswap_64
#define bswap_64 __builtin_bswap64
#endif
#include <atomic>
#include <cstring>
......@@ -75,7 +63,7 @@ constexpr unsigned MSB( T x ) {
template< typename T >
constexpr T fill( T x ) {
return x ? x | fill( x >> 1 ) : x;
return x ? x | compiletime::fill( x >> 1 ) : x;
}
template< typename T >
......@@ -83,6 +71,77 @@ constexpr size_t sizeOf() {
return std::is_empty< T >::value ? 0 : sizeof( T );
}
template< typename T >
constexpr T ones( int bits )
{
return bits ? ( T(1) << ( bits - 1 ) ) | compiletime::ones< T >( bits - 1 ) : 0;
}
}
using compiletime::ones;
template< typename L, typename H >
struct bvpair
{
L low; H high;
constexpr bvpair( L l, H h = 0 ) : low( l ), high( h ) {}
constexpr bvpair() = default;
explicit constexpr operator bool() const { return low || high; }
constexpr bvpair operator<<( int s ) const
{
int rem = 8 * sizeof( low ) - s;
int unshift = std::max( rem, 0 );
int shift = rem < 0 ? -rem : 0;
H carry = ( low & ~ones< L >( unshift ) ) >> unshift;
return bvpair( low << s, ( high << s ) | ( carry << shift ) );
}
constexpr bvpair operator>>( int s ) const
{
int rem = 8 * sizeof( low ) - s;
int unshift = std::max( rem, 0 );
int shift = rem < 0 ? -rem : 0;
L carry = L( high & ones< H >( s ) ) << unshift;
return bvpair( ( low >> s ) | ( carry >> shift ), high >> s );
}
constexpr bvpair operator&( bvpair o ) const { return bvpair( o.low & low, o.high & high ); }
constexpr bvpair operator|( bvpair o ) const { return bvpair( o.low | low, o.high | high ); }
bvpair &operator|=( bvpair o ) { return *this = *this | o; }
constexpr bool operator==( bvpair o ) const { return o.low == low && o.high == high; }
constexpr bool operator!=( bvpair o ) const { return o.low != low || o.high != high; }
constexpr bvpair operator+() const { return *this; }
friend std::ostream &operator<<( std::ostream &o, bvpair p ) {
return o << p.high << "_" << p.low; }
} __attribute__((packed));
template< int i > struct _bitvec { using T = typename _bitvec< i + 1 >::T; };
template<> struct _bitvec< 8 > { using T = uint8_t; };
template<> struct _bitvec< 16 > { using T = uint16_t; };
template<> struct _bitvec< 32 > { using T = uint32_t; };
template<> struct _bitvec< 64 > { using T = uint64_t; };
template<> struct _bitvec< 80 > { using T = bvpair< uint64_t, uint16_t >; };
template<> struct _bitvec< 128 > { using T = bvpair< uint64_t, uint64_t >; };
template< int i > using bitvec = typename _bitvec< i >::T;
namespace {
uint32_t mixdown( uint64_t i ) /* due to Thomas Wang */
{
i = (~i) + (i << 18);
i = i ^ (i >> 31);
i = i * 21;
i = i ^ (i >> 11);
i = i + (i << 6);
i = i ^ (i >> 22);
return i;
}
__attribute__((unused)) uint32_t mixdown( uint32_t a, uint32_t b )
{
return mixdown( ( uint64_t( a ) << 32 ) | uint64_t( b ) );
}
}
/*
......@@ -144,28 +203,46 @@ static inline number withoutMSB( number x ) {
return x & ~onlyMSB( x );
}
inline uint64_t bitshift( uint64_t t, int shift ) {
#if BYTE_ORDER == LITTLE_ENDIAN
return bswap_64( shift < 0 ? bswap_64( t << -shift ) : bswap_64( t >> shift ) );
#else
inline constexpr uint64_t bitshift( uint64_t t, int shift ) {
return shift < 0 ? ( t << -shift ) : ( t >> shift );
#endif
}
inline constexpr uint64_t mask( int first, int count ) {
return (uint64_t(-1) << first) & (uint64_t(-1) >> (64 - first - count));
}
struct BitPointer {
using Storage = uint32_t;
static constexpr int storageBits = sizeof( Storage ) * 8;
BitPointer() : base( nullptr ), _bitoffset( 0 ) {}
template< typename T > BitPointer( T *t, int offset = 0 )
: base( static_cast< void * >( t ) ), _bitoffset( offset )
{
normalize();
}
uint32_t &word() { ASSERT( valid() ); return *static_cast< uint32_t * >( base ); }
uint64_t &dword() { ASSERT( valid() ); return *static_cast< uint64_t * >( base ); }
template< typename T >
T &ref() { ASSERT( valid() ); return *static_cast< T * >( base ); }