]> git.mxchange.org Git - simgear.git/blobdiff - simgear/timing/timestamp.cxx
Don't waste space with too huge stl containers.
[simgear.git] / simgear / timing / timestamp.cxx
index af4c7ea217c06a682e87ce18fe1cd3b15d3f23db..f2eefcf583e5ab7db544921e8baadb72d0b7ce1f 100644 (file)
@@ -19,7 +19,7 @@
 //
 // You should have received a copy of the GNU General Public License
 // along with this program; if not, write to the Free Software
-// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 //
 // $Id$
 
 #  include <simgear_config.h>
 #endif
 
-#ifdef HAVE_WINDOWS_H
-#  include <windows.h>
-#endif
-
 #include <simgear/compiler.h>
 
-#ifdef SG_HAVE_STD_INCLUDES
-#  include <ctime>
-#else
-#  include <time.h>
-#endif
+#include <ctime>
 
 #ifdef HAVE_SYS_TIMEB_H
 #  include <sys/timeb.h> // for ftime() and struct timeb
 #  include <sys/time.h>  // for get/setitimer, gettimeofday, struct timeval
 #endif
 
-// -dw- want to use metrowerks time.h
-#ifdef macintosh
-#  include <time.h>
-#  include <timer.h>
-#endif
-
 #ifdef WIN32
 #  include <windows.h>
 #  if defined( __CYGWIN__ ) || defined( __CYGWIN32__ )
 
 
 void SGTimeStamp::stamp() {
-#if defined( WIN32 )
+#if defined( WIN32 ) && !defined(__CYGWIN__)
     unsigned int t;
     t = timeGetTime();
-    seconds = 0;
-    usec =  t * 1000;
+    seconds = t / 1000;
+    usec = ( t - ( seconds * 1000 ) ) * 1000;
 #elif defined( HAVE_GETTIMEOFDAY )
     struct timeval current;
     struct timezone tz;
@@ -91,13 +77,6 @@ void SGTimeStamp::stamp() {
     ftime(&current);
     seconds = current.time;
     usec = current.millitm * 1000;
-// -dw- uses time manager
-#elif defined( macintosh )
-    UnsignedWide ms;
-    Microseconds(&ms);
-       
-    seconds = ms.lo / 1000000;
-    usec = ms.lo - ( seconds * 1000000 );
 #else
 # error Port me
 #endif
@@ -105,20 +84,12 @@ void SGTimeStamp::stamp() {
 
 // increment the time stamp by the number of microseconds (usec)
 SGTimeStamp operator + (const SGTimeStamp& t, const long& m) {
-#if defined( WIN32 )
-    return SGTimeStamp( 0, t.usec + m );
-#else
     return SGTimeStamp( t.seconds + ( t.usec + m ) / 1000000,
                        ( t.usec + m ) % 1000000 );
-#endif
 }
 
 // difference between time stamps in microseconds (usec)
 long operator - (const SGTimeStamp& a, const SGTimeStamp& b)
 {
-#if defined( WIN32 )
-    return a.usec - b.usec;
-#else
     return 1000000 * (a.seconds - b.seconds) + (a.usec - b.usec);
-#endif
 }