CommonPreamble.h File Reference

Go to the source code of this file.

Namespaces

namespace  std

Classes

struct  std::hash< fennel::OpaqueInteger< T, Dummy > >
class  VectorOfUint

Typedefs

typedef unsigned uint

Functions

void * operator new (size_t, fennel::PBuffer pBuffer)
void * operator new[] (size_t, fennel::PBuffer pBuffer)
template<class T>
void deleteAndNullify (T *&p)
 Delete an object and set the pointer associated with it to NULL.
template<class T>
void deleteAndNullifyArray (T *&p)
 Delete an array and set the pointer associated with it to NULL.
template<class T>
alignRoundDown (T t)
 Align a size DOWN to the next alignment multiple.
template<class T>
T * alignRoundPtrDown (T *t)
 Align a pointer DOWN (assuming sizeof(uint) == sizeof(void *)).
template<class T>
alignRoundUp (T t)
 Align a size UP to the next alignment multiple.
template<class T>
T * alignRoundPtrUp (T *t)
 Align a pointer UP.
uint bytesForBits (uint cBits)
void FENNEL_COMMON_EXPORT hexDump (std::ostream &, void const *, uint cb, uint cbOffsetInitial=0)
template<class Numeric>
Numeric sqr (Numeric n)
int FENNEL_COMMON_EXPORT getCurrentThreadId ()
std::logic_error FENNEL_COMMON_EXPORT constructAssertion (char const *pFilename, int lineNum, char const *condExpr)


Typedef Documentation

typedef unsigned uint

Definition at line 94 of file CommonPreamble.h.


Function Documentation

template<class T>
T alignRoundDown ( t  )  [inline]

Align a size DOWN to the next alignment multiple.

Definition at line 330 of file CommonPreamble.h.

Referenced by alignRoundPtrDown(), and alignRoundUp().

00331 {
00332     return t & ~ARCH_ALIGN_MASK;
00333 }

template<class T>
T* alignRoundPtrDown ( T *  t  )  [inline]

Align a pointer DOWN (assuming sizeof(uint) == sizeof(void *)).

Definition at line 339 of file CommonPreamble.h.

References alignRoundDown().

00340 {
00341     return (T *) alignRoundDown(uint(t));
00342 }

template<class T>
T* alignRoundPtrUp ( T *  t  )  [inline]

Align a pointer UP.

Definition at line 361 of file CommonPreamble.h.

References alignRoundUp().

00362 {
00363     return (T *) alignRoundUp(uint(t));
00364 }

template<class T>
T alignRoundUp ( t  )  [inline]

Align a size UP to the next alignment multiple.

Definition at line 348 of file CommonPreamble.h.

References alignRoundDown().

Referenced by alignRoundPtrUp(), TupleAccessor::compute(), TupleAccessor::getBufferByteCount(), and TupleAccessor::getByteCount().

00349 {
00350     if (t & ARCH_ALIGN_MASK) {
00351         return alignRoundDown(t) + ARCH_ALIGN_BYTES;
00352     } else {
00353         return t;
00354     }
00355 }

uint bytesForBits ( uint  cBits  )  [inline]

Definition at line 367 of file CommonPreamble.h.

Referenced by TupleAccessor::compute().

00368 {
00369     return (cBits >> 3) + ((cBits & 7) ? 1 : 0);
00370 }

std::logic_error FENNEL_COMMON_EXPORT constructAssertion ( char const *  pFilename,
int  lineNum,
char const *  condExpr 
)

Definition at line 64 of file Memory.cpp.

00066 {
00067     boost::format fmt("Assertion `%1%' failed at line %2% in file %3%");
00068     return std::logic_error(
00069         (fmt % condExpr % lineNum % pFilename).str());
00070 }

template<class T>
void deleteAndNullify ( T *&  p  )  [inline]

Delete an object and set the pointer associated with it to NULL.

Definition at line 284 of file CommonPreamble.h.

Referenced by CacheImpl< PageT, VictimPolicyT >::allocatePages(), CacheImpl< PageT, VictimPolicyT >::closeImpl(), Java_net_sf_farrago_fennel_FennelStorage_deleteExecutionHandle(), ThreadPoolBase::stop(), IoCompletionPortScheduler::stop(), AioSignalScheduler::stop(), and CmdInterpreter::visit().

00285 {
00286     if (p) {
00287         delete p;
00288         p = NULL;
00289     }
00290 }

template<class T>
void deleteAndNullifyArray ( T *&  p  )  [inline]

Delete an array and set the pointer associated with it to NULL.

Definition at line 297 of file CommonPreamble.h.

00298 {
00299     if (p) {
00300         delete [] p;
00301         p = NULL;
00302     }
00303 }

int FENNEL_COMMON_EXPORT getCurrentThreadId (  ) 

Definition at line 72 of file Memory.cpp.

Referenced by LockHolderId::assignFrom(), and get_tid().

00073 {
00074 #ifdef __MSVC__
00075     return static_cast<int>(GetCurrentThreadId());
00076 #else
00077     return static_cast<int>(pthread_self());
00078 #endif
00079 }

void FENNEL_COMMON_EXPORT hexDump ( std::ostream &  ,
void const *  ,
uint  cb,
uint  cbOffsetInitial = 0 
)

Definition at line 81 of file Memory.cpp.

References min().

Referenced by TuplePrinter::visitBytes().

00082 {
00083     boost::io::ios_all_saver streamStateSaver(o);
00084 
00085     PConstBuffer b = (PConstBuffer) v;
00086     uint cbLine = 16,cbThis;
00087     o.fill('0');
00088     for (; cb; cb -= cbThis, cbDone += cbThis) {
00089         cbThis = std::min(cbLine,cb);
00090         o << std::hex;
00091         o.width(4);
00092         o << cbDone << ": ";
00093         uint i;
00094         for (i = 0; i < cbThis; i++, b++) {
00095             o.width(2);
00096             o << (uint) *b << " ";
00097         }
00098         for (i = cbThis; i < cbLine; i++) {
00099             o << "   ";
00100         }
00101         o << "| ";
00102         for (i = 0, b -= cbThis; i < cbThis; i++, b++) {
00103             if (isprint(*b)) {
00104                 o << *b;
00105             } else {
00106                 o << " ";
00107             }
00108         }
00109         o << std::endl;
00110     }
00111 }

void* operator new ( size_t  ,
fennel::PBuffer  pBuffer 
) [inline]

Definition at line 263 of file CommonPreamble.h.

00264 {
00265     return pBuffer;
00266 }

void* operator new[] ( size_t  ,
fennel::PBuffer  pBuffer 
) [inline]

Definition at line 268 of file CommonPreamble.h.

00269 {
00270     return pBuffer;
00271 }

template<class Numeric>
Numeric sqr ( Numeric  n  )  [inline]

Definition at line 383 of file CommonPreamble.h.

00384 {
00385     return n*n;
00386 }


Generated on Mon Jun 22 04:00:22 2009 for Fennel by  doxygen 1.5.1