SystemBase.h

Go to the documentation of this file.
00001 /****************** <VPR heading BEGIN do not edit this line> *****************
00002  *
00003  * VR Juggler Portable Runtime
00004  *
00005  * Original Authors:
00006  *   Allen Bierbaum, Patrick Hartling, Kevin Meinert, Carolina Cruz-Neira
00007  *
00008  * -----------------------------------------------------------------
00009  * File:          $RCSfile$
00010  * Date modified: $Date: 2005-06-15 09:11:46 -0500 (Wed, 15 Jun 2005) $
00011  * Version:       $Revision: 17686 $
00012  * -----------------------------------------------------------------
00013  *
00014  ****************** <VPR heading END do not edit this line> ******************/
00015 
00016 /*************** <auto-copyright.pl BEGIN do not edit this line> **************
00017  *
00018  * VR Juggler is (C) Copyright 1998-2005 by Iowa State University
00019  *
00020  * Original Authors:
00021  *   Allen Bierbaum, Christopher Just,
00022  *   Patrick Hartling, Kevin Meinert,
00023  *   Carolina Cruz-Neira, Albert Baker
00024  *
00025  * This library is free software; you can redistribute it and/or
00026  * modify it under the terms of the GNU Library General Public
00027  * License as published by the Free Software Foundation; either
00028  * version 2 of the License, or (at your option) any later version.
00029  *
00030  * This library is distributed in the hope that it will be useful,
00031  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00032  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00033  * Library General Public License for more details.
00034  *
00035  * You should have received a copy of the GNU Library General Public
00036  * License along with this library; if not, write to the
00037  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00038  * Boston, MA 02111-1307, USA.
00039  *
00040  *************** <auto-copyright.pl END do not edit this line> ***************/
00041 
00042 #ifndef _VPR_SYSTEM_BASE_H_
00043 #define _VPR_SYSTEM_BASE_H_
00044 
00045 #include <vpr/vprConfig.h>
00046 #include <string>
00047 
00048 #ifdef HAVE_SYS_TIME_H
00049 #include <sys/time.h>
00050 #endif
00051 
00052 
00053 namespace vpr
00054 {
00055 
00056 #if defined(HAVE_TIMEVAL) && ! defined(VPR_OS_Windows)
00057 
00060 typedef struct timeval TimeVal;
00061 #else
00062 
00069 struct TimeVal
00070 {
00071    long tv_sec;           
00072    long tv_usec;          
00073 };
00074 #endif
00075 
00076 #ifdef HAVE_TIMEZONE
00077 typedef struct timezone TimeZone;
00078 #else
00079 
00085 struct TimeZone
00086 {
00087    int tv_minuteswest;    
00088    int tv_dsttime;        
00089 };
00090 #endif
00091 
00099 class VPR_CLASS_API SystemBase
00100 {
00101 public:
00110    static int getEndian()
00111    {
00112       union
00113       {
00114          char   c[sizeof(short)];
00115          short  value;
00116       } endian;
00117 
00118       // The way this works is that we access the first byte of endian.value
00119       // directly.  If it is 1, the host treats that as the high-order byte.
00120       // Otherwise, it is the low-order byte.
00121       endian.value = 256;
00122 
00123       return endian.c[0];
00124    }
00125 
00132    static bool isLittleEndian()
00133    {
00134       return(getEndian() == 0);
00135    }
00136 
00143    static bool isBigEndian()
00144    {
00145       return(getEndian() == 1);
00146    }
00147 
00153    static std::string getCallStack();
00154 };
00155 
00156 } // End of vpr namespace
00157 
00158 
00159 #endif   /* _VPR_SYSTEM_BASE_H_ */

Generated on Thu Jan 4 10:52:11 2007 for VR Juggler Portable Runtime by  doxygen 1.5.1