Browse Source

*** empty log message ***

Mike Goslin 25 years ago
parent
commit
2b5709f63a

+ 17 - 0
panda/src/express/clockObject.cxx

@@ -52,3 +52,20 @@ tick() {
 
 
   _frame_count++;
   _frame_count++;
 }
 }
+
+////////////////////////////////////////////////////////////////////
+//     Function: TimeVal::contructor
+//       Access: Public
+//  Description:
+////////////////////////////////////////////////////////////////////
+TimeVal::
+TimeVal(void) {
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: get_time_of_day 
+//  Description:
+////////////////////////////////////////////////////////////////////
+void get_time_of_day(TimeVal &tv) {
+  get_true_time_of_day(tv.tv[0], tv.tv[1]);
+}

+ 12 - 0
panda/src/express/clockObject.h

@@ -11,6 +11,18 @@
 #include "trueClock.h"
 #include "trueClock.h"
 #include "config_express.h"
 #include "config_express.h"
 
 
+class EXPCL_PANDAEXPRESS TimeVal {
+PUBLISHED:
+  TimeVal();
+  ulong tv[2];
+};
+
+BEGIN_PUBLISH
+
+EXPCL_PANDAEXPRESS void get_time_of_day(TimeVal &tv);
+
+END_PUBLISH
+
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //       Class : ClockObject
 //       Class : ClockObject
 // Description : A ClockObject keeps track of elapsed real time and
 // Description : A ClockObject keeps track of elapsed real time and

+ 29 - 0
panda/src/express/trueClock.cxx

@@ -29,6 +29,12 @@ static PN_int64 _frequency;
 static PN_int64 _init_count;
 static PN_int64 _init_count;
 static long _init_sec;
 static long _init_sec;
 
 
+void get_true_time_of_day(ulong &sec, ulong &usec) {
+  struct timeb tb;
+  ftime(&tb);
+  sec = tb.time;
+  usec = (ulong)(tb.millitm * 1000.0);
+}
 
 
 double TrueClock::
 double TrueClock::
 get_real_time() const {
 get_real_time() const {
@@ -105,6 +111,10 @@ timer_handler(int) {
   return -1;
   return -1;
 }
 }
 
 
+void get_true_time_of_day(ulong &sec, ulong &msec) {
+  cerr << "get_true_time_of_day() not implemented!" << endl;
+}
+
 double TrueClock::
 double TrueClock::
 get_real_time() const {
 get_real_time() const {
   return (double) _sec + ((double) _msec / 1000.0);
   return (double) _sec + ((double) _msec / 1000.0);
@@ -146,6 +156,25 @@ TrueClock() {
 
 
 static long _init_sec;
 static long _init_sec;
 
 
+void get_true_time_of_day(ulong &sec, ulong &msec) {
+  struct timeval tv;
+  int result;
+
+#ifdef GETTIMEOFDAY_ONE_PARAM
+  result = gettimeofday(&tv);
+#else
+  result = gettimeofday(&tv, (struct timezone *)NULL);
+#endif
+
+  if (result < 0) {
+    sec = 0;
+    msec = 0;
+    // Error in gettimeofday().
+    return;
+  }
+  sec = tv.tv_sec;
+  msec = tv.tv_usec; 
+}
 
 
 double TrueClock::
 double TrueClock::
 get_real_time() const {
 get_real_time() const {

+ 3 - 0
panda/src/express/trueClock.h

@@ -7,6 +7,7 @@
 #define TRUECLOCK_H
 #define TRUECLOCK_H
 
 
 #include <pandabase.h>
 #include <pandabase.h>
+#include "typedef.h"
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //       Class : TrueClock
 //       Class : TrueClock
@@ -34,6 +35,8 @@ protected:
   static TrueClock *_global_ptr;
   static TrueClock *_global_ptr;
 };
 };
 
 
+void get_true_time_of_day(ulong &sec, ulong &usec);
+
 #include "trueClock.I"
 #include "trueClock.I"
   
   
 #endif
 #endif