/*
- * Copyright (c) 2003-2005 The Regents of The University of Michigan
+ * Copyright (c) 2007-2008 The Regents of The University of Michigan
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
#ifndef __BASE_BITUNION_HH__
#define __BASE_BITUNION_HH__
-#include <inttypes.h>
#include "base/bitfield.hh"
+#include "base/types.hh"
-// The following implements the BitUnion system of defining bitfields
+// The following implements the BitUnion system of defining bitfields
//on top of an underlying class. This is done through the pervasive use of
//both named and unnamed unions which all contain the same actual storage.
//Since they're unioned with each other, all of these storage locations
class Bitfield : public BitfieldBase<Type>
{
public:
- operator uint64_t () const
+ operator const uint64_t () const
{
return this->getBits(first, last);
}
class BitfieldWO : public Bitfield<first, last>
{
private:
- operator uint64_t () const;
+ operator const uint64_t () const;
public:
using Bitfield<first, last>::operator=;
class SignedBitfield : public BitfieldBase<Type>
{
public:
- operator int64_t () const
+ operator const int64_t () const
{
return sext<first - last + 1>(this->getBits(first, last));
}
class SignedBitfieldWO : public SignedBitfield<first, last>
{
private:
- operator int64_t () const;
+ operator const int64_t () const;
public:
int64_t operator=(const int64_t _data)
BitUnionOperators() {}
- operator Type () const
+ operator const Type () const
{
return Base::__data;
}
//bitfields which are defined in the union, creating shared storage with no
//overhead.
#define __BitUnion(type, name) \
- namespace BitfieldUnderlyingClasses \
- { \
- class name; \
- } \
- class BitfieldUnderlyingClasses::name : \
+ class BitfieldUnderlyingClasses##name : \
public BitfieldBackend::BitfieldTypes<type> \
{ \
public: \
}; \
}; \
typedef BitfieldBackend::BitUnionOperators< \
- BitfieldUnderlyingClasses::name::__DataType, \
- BitfieldUnderlyingClasses::name> name;
+ BitfieldUnderlyingClasses##name::__DataType, \
+ BitfieldUnderlyingClasses##name> name;
//This sets up a bitfield which has other bitfields nested inside of it. The
//__data member functions like the "underlying storage" of the top level
//do so.
#define EndSubBitUnion(name) \
}; \
- inline operator const __DataType () \
+ inline operator const __DataType () const \
{ return __data; } \
\
inline const __DataType operator = (const __DataType & _data) \