Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

2004-04-07 Russell M. Taylor II <taylorr@cs.unc.edu>

        * vrpn_Shared.C : Modified all of VRPN to use calls to a new
                function vrpn_gettimeofday() rather than the standard
                gettimeofday() to avoid exporting gettimeofday().  On
                all but Windows with WINSOCK, this is defined back to
                gettimeofday().  On Windows with WINSOCK, it is the
                function that implements gettimeofday().  By editing
                a flag in vrpn_Configure.h, VRPN will still export
                gettimeofday; otherwise, it no longer does on any
                operating system.
        * vrpn_Shared.h : Same.
        * vrpn_Configure.h : Modified to include an optional parameter
                that will export vrpn_gettimeofday() as gettimeofday() and also
                'struct timezone' when it is set, but not otherwise.
        * time_test.cpp : Using vrpn_gettimeofday() not gettimeofday()
        * vrpn_3Space.C : Same.
        * vrpn_ADBox.C : Same.
        * vrpn_Analog.C : Same.
        * vrpn_Analog_3dt.C : Same.
        * vrpn_Analog_Output.C : Same.
        * vrpn_Analog_Radamec_SPI.C : Same.
        * vrpn_BaseClass.C : Same.
        * vrpn_Button.C : Same.
        * vrpn_CerealBox.C : Same.
        * vrpn_Clock.C : Same.
        * vrpn_Connection.C : Same.
        * vrpn_Dial.C : Same.
        * vrpn_DirectXFFJoystick.C : Same.
        * vrpn_Dyna. : Same.
        * vrpn_FileController.C : Same.
        * vrpn_Flock.C : Same.
        * vrpn_Flock_Parallel.C : Same.
        * vrpn_ForceDevice.C : Same.
        * vrpn_ForewardController.C : Same.
        * vrpn_GlobalHapticsOrb.C : Same.
        * vrpn_ImmersionBox.C : Same.
        * vrpn_Joylin.C : Same.
        * vrpn_Joywin32.C : Same.
        * vrpn_Magellan.C : Same.
        * vrpn_Mutex.C : Same.
        * vrpn_Nidaq.C : Same.
        * vrpn_Nidaq.h : Same.
        * vrpn_Poser.C : Same.
        * vrpn_Poser_Analog.C : Same.
        * vrpn_RedundantTransmission.C : Sam.e
        * vrpn_Router.C : Same.
        * vrpn_Serial.C : Same.
        * vrpn_SharedObject.C : Same.
        * vrpn_Sound.C : Same.
        * vrpn_Spaceball.C : Same.
        * vrpn_TempImager.C : Same.
        * vrpn_Text.C : Same.
        * vrpn_Tng.C : Same.
        * vrpn_Tracker.C : Same.
        * vrpn_Tracker_AnalogFly.C : Same.
        * vrpn_Tracker_ButtonFly.C : Same.
        * vrpn_Tracker_DTrack.C : Same.
        * vrpn_Tracker_Fastrak.C : Same.
        * vrpn_Tracker_Liberty.C : Same.
        * vrpn_Tracker_isense.C : Same.
        * vrpn_UNC_Joystick.C : Same.
        * vrpn_Wanda.C : Same.
        * vrpn_Zaber.C : Same.
        * vrpn_nikon_controls.C : Same.
        * vrpn_FileConnection.C : Same.  Also, modified some calls to
                advance_currentLogEntry() so that they were funtion
                calls so that the code would compile.  Not sure how
                they compiled before...
  • Loading branch information...
commit ad5c21dca5497efc5d6b3a6f31458e740ba96487 1 parent 9ad00e1
taylorr authored
Showing with 420 additions and 291 deletions.
  1. +70 −0 ChangeLog
  2. +3 −3 time_test.cpp
  3. +2 −2 vrpn_3Space.C
  4. +2 −2 vrpn_ADBox.C
  5. +3 −3 vrpn_Analog.C
  6. +3 −3 vrpn_Analog_5dt.C
  7. +4 −4 vrpn_Analog_Output.C
  8. +3 −3 vrpn_Analog_Radamec_SPI.C
  9. +4 −4 vrpn_BaseClass.C
  10. +8 −8 vrpn_Button.C
  11. +3 −3 vrpn_CerealBox.C
  12. +11 −11 vrpn_Clock.C
  13. +13 −1 vrpn_Configure.h
  14. +16 −18 vrpn_Connection.C
  15. +2 −2 vrpn_Dial.C
  16. +6 −6 vrpn_DirectXFFJoystick.C
  17. +2 −2 vrpn_Dyna.C
  18. +9 −9 vrpn_FileConnection.C
  19. +3 −3 vrpn_FileController.C
  20. +4 −4 vrpn_Flock.C
  21. +3 −3 vrpn_Flock_Parallel.C
  22. +19 −19 vrpn_ForceDevice.C
  23. +2 −2 vrpn_ForwarderController.C
  24. +3 −3 vrpn_GlobalHapticsOrb.C
  25. +7 −7 vrpn_ImmersionBox.C
  26. +2 −3 vrpn_Joylin.C
  27. +3 −3 vrpn_Joywin32.C
  28. +3 −3 vrpn_Magellan.C
  29. +11 −11 vrpn_Mutex.C
  30. +4 −4 vrpn_Nidaq.C
  31. +1 −1  vrpn_Nidaq.h
  32. +1 −1  vrpn_Poser.C
  33. +2 −2 vrpn_Poser_Analog.C
  34. +4 −4 vrpn_RedundantTransmission.C
  35. +1 −1  vrpn_Router.C
  36. +2 −2 vrpn_Serial.C
  37. +47 −18 vrpn_Shared.C
  38. +40 −12 vrpn_Shared.h
  39. +9 −9 vrpn_SharedObject.C
  40. +22 −22 vrpn_Sound.C
  41. +2 −2 vrpn_Spaceball.C
  42. +4 −4 vrpn_TempImager.C
  43. +1 −1  vrpn_Text.C
  44. +7 −7 vrpn_Tng3.C
  45. +12 −12 vrpn_Tracker.C
  46. +3 −3 vrpn_Tracker_AnalogFly.C
  47. +2 −2 vrpn_Tracker_ButtonFly.C
  48. +1 −8 vrpn_Tracker_DTrack.C
  49. +3 −3 vrpn_Tracker_Fastrak.C
  50. +4 −4 vrpn_Tracker_Liberty.C
  51. +10 −10 vrpn_Tracker_isense.C
  52. +2 −2 vrpn_UNC_Joystick.C
  53. +1 −1  vrpn_VPJoystick.C
  54. +2 −2 vrpn_Wanda.C
  55. +4 −4 vrpn_Zaber.C
  56. +5 −5 vrpn_nikon_controls.C
View
70 ChangeLog
@@ -1,3 +1,73 @@
+2004-04-07 Russell M. Taylor II <taylorr@cs.unc.edu>
+
+ * vrpn_Shared.C : Modified all of VRPN to use calls to a new
+ function vrpn_gettimeofday() rather than the standard
+ gettimeofday() to avoid exporting gettimeofday(). On
+ all but Windows with WINSOCK, this is defined back to
+ gettimeofday(). On Windows with WINSOCK, it is the
+ function that implements gettimeofday(). By editing
+ a flag in vrpn_Configure.h, VRPN will still export
+ gettimeofday; otherwise, it no longer does on any
+ operating system.
+ * vrpn_Shared.h : Same.
+ * vrpn_Configure.h : Modified to include an optional parameter
+ that will export vrpn_gettimeofday() as gettimeofday() and also
+ 'struct timezone' when it is set, but not otherwise.
+ * time_test.cpp : Using vrpn_gettimeofday() not gettimeofday()
+ * vrpn_3Space.C : Same.
+ * vrpn_ADBox.C : Same.
+ * vrpn_Analog.C : Same.
+ * vrpn_Analog_3dt.C : Same.
+ * vrpn_Analog_Output.C : Same.
+ * vrpn_Analog_Radamec_SPI.C : Same.
+ * vrpn_BaseClass.C : Same.
+ * vrpn_Button.C : Same.
+ * vrpn_CerealBox.C : Same.
+ * vrpn_Clock.C : Same.
+ * vrpn_Connection.C : Same.
+ * vrpn_Dial.C : Same.
+ * vrpn_DirectXFFJoystick.C : Same.
+ * vrpn_Dyna. : Same.
+ * vrpn_FileController.C : Same.
+ * vrpn_Flock.C : Same.
+ * vrpn_Flock_Parallel.C : Same.
+ * vrpn_ForceDevice.C : Same.
+ * vrpn_ForewardController.C : Same.
+ * vrpn_GlobalHapticsOrb.C : Same.
+ * vrpn_ImmersionBox.C : Same.
+ * vrpn_Joylin.C : Same.
+ * vrpn_Joywin32.C : Same.
+ * vrpn_Magellan.C : Same.
+ * vrpn_Mutex.C : Same.
+ * vrpn_Nidaq.C : Same.
+ * vrpn_Nidaq.h : Same.
+ * vrpn_Poser.C : Same.
+ * vrpn_Poser_Analog.C : Same.
+ * vrpn_RedundantTransmission.C : Sam.e
+ * vrpn_Router.C : Same.
+ * vrpn_Serial.C : Same.
+ * vrpn_SharedObject.C : Same.
+ * vrpn_Sound.C : Same.
+ * vrpn_Spaceball.C : Same.
+ * vrpn_TempImager.C : Same.
+ * vrpn_Text.C : Same.
+ * vrpn_Tng.C : Same.
+ * vrpn_Tracker.C : Same.
+ * vrpn_Tracker_AnalogFly.C : Same.
+ * vrpn_Tracker_ButtonFly.C : Same.
+ * vrpn_Tracker_DTrack.C : Same.
+ * vrpn_Tracker_Fastrak.C : Same.
+ * vrpn_Tracker_Liberty.C : Same.
+ * vrpn_Tracker_isense.C : Same.
+ * vrpn_UNC_Joystick.C : Same.
+ * vrpn_Wanda.C : Same.
+ * vrpn_Zaber.C : Same.
+ * vrpn_nikon_controls.C : Same.
+ * vrpn_FileConnection.C : Same. Also, modified some calls to
+ advance_currentLogEntry() so that they were funtion
+ calls so that the code would compile. Not sure how
+ they compiled before...
+
2004-03-21 Russell M. Taylor II <taylorr@cs.unc.edu>
* vrpn_CerealBox.C : Fixed a bug that encoded the negative tick
View
6 time_test.cpp
@@ -74,13 +74,13 @@ int main(int argc, char *argv[]) {
}
*/
- /* Checking the gettimeofday() function for monotonicity and step size */
+ /* Checking the vrpn_gettimeofday() function for monotonicity and step size */
struct timeval last_time, this_time;
double skip;
- gettimeofday(&last_time, NULL);
+ vrpn_gettimeofday(&last_time, NULL);
printf("Should be no further output if things are working\n");
while (true) {
- gettimeofday(&this_time, NULL);
+ vrpn_gettimeofday(&this_time, NULL);
skip = vrpn_TimevalMsecs(vrpn_TimevalDiff(this_time, last_time));
if (skip > 50) {
printf("Skipped forward %lg microseconds\n", skip);
View
4 vrpn_3Space.C
@@ -153,7 +153,7 @@ void vrpn_Tracker_3Space::reset()
}
fprintf(stderr, " (at the end of 3Space reset routine)\n");
- gettimeofday(&timestamp, NULL); // Set watchdog now
+ vrpn_gettimeofday(&timestamp, NULL); // Set watchdog now
status = vrpn_TRACKER_SYNCING; // We're trying for a new reading
}
@@ -182,7 +182,7 @@ int vrpn_Tracker_3Space::get_report(void)
// Got the first character of a report -- go into PARTIAL mode
// and say that we got one character at this time.
bufcount = 1;
- gettimeofday(&timestamp, NULL);
+ vrpn_gettimeofday(&timestamp, NULL);
status = vrpn_TRACKER_PARTIAL;
}
View
4 vrpn_ADBox.C
@@ -37,7 +37,7 @@ vrpn_ADBox::vrpn_ADBox(char* name, vrpn_Connection *c,
}
// find out what time it is - needed?
- gettimeofday(&timestamp, 0);
+ vrpn_gettimeofday(&timestamp, 0);
vrpn_Analog::timestamp = timestamp;
vrpn_Button::timestamp = timestamp;
}
@@ -122,7 +122,7 @@ void vrpn_ADBox::mainloop()
}
}
- gettimeofday(&timestamp, 0);
+ vrpn_gettimeofday(&timestamp, 0);
vrpn_Analog::timestamp = timestamp;
vrpn_Button::timestamp = timestamp;
View
6 vrpn_Analog.C
@@ -103,7 +103,7 @@ void vrpn_Analog::report (vrpn_uint32 class_of_service, const struct timeval tim
// Replace the time value with the current time if the user passed in the
// constant time referring to "now".
if ( (time.tv_sec == vrpn_ANALOG_NOW.tv_sec) && (time.tv_usec == vrpn_ANALOG_NOW.tv_sec) ) {
- gettimeofday(&timestamp, NULL);
+ vrpn_gettimeofday(&timestamp, NULL);
}
len = vrpn_Analog::encode_to(msgbuf);
#ifdef VERBOSE
@@ -147,7 +147,7 @@ vrpn_Serial_Analog::vrpn_Serial_Analog (const char * name, vrpn_Connection * c,
// Reset the tracker and find out what time it is
status = vrpn_ANALOG_RESETTING;
- gettimeofday(&timestamp, NULL);
+ vrpn_gettimeofday(&timestamp, NULL);
}
vrpn_Serial_Analog::~vrpn_Serial_Analog ()
@@ -304,7 +304,7 @@ vrpn_Analog_Remote::vrpn_Analog_Remote (const char * name,
for (i = 0; i < vrpn_CHANNEL_MAX; i++) {
channel[i] = last[i] = 0;
}
- gettimeofday(&timestamp, NULL);
+ vrpn_gettimeofday(&timestamp, NULL);
}
// virtual
View
6 vrpn_Analog_5dt.C
@@ -173,7 +173,7 @@ vrpn_5dt::reset (void)
// We're now entering the syncing mode which send the read command to the glove
_status = STATUS_SYNCING;
- gettimeofday (&timestamp, NULL); // Set watchdog now
+ vrpn_gettimeofday (&timestamp, NULL); // Set watchdog now
return 0;
}
@@ -231,7 +231,7 @@ void vrpn_5dt::get_report (void)
}
// XXX This should be called when the first character of a report is read.
- gettimeofday(&timestamp, NULL);
+ vrpn_gettimeofday(&timestamp, NULL);
//--------------------------------------------------------------------
// Read as many bytes of this report as we can, storing them
@@ -371,7 +371,7 @@ void vrpn_5dt::mainloop ()
// if there is a report ready (ie, if THIS device is still operating).
get_report();
struct timeval current_time;
- gettimeofday(&current_time, NULL);
+ vrpn_gettimeofday(&current_time, NULL);
if ( duration(current_time,timestamp) > MAX_TIME_INTERVAL)
{
sprintf (l_errmsg, "vrpn_5dt::mainloop: Timeout... current_time=%ld:%ld, timestamp=%ld:%ld",
View
8 vrpn_Analog_Output.C
@@ -178,7 +178,7 @@ bool vrpn_Analog_Output_Server::report_num_channels( vrpn_uint32 class_of_servic
vrpn_int32 len = sizeof( vrpn_int32 );;
encode_num_channels_to( msgbuf, this->o_num_channel );
- gettimeofday( &o_timestamp, NULL );
+ vrpn_gettimeofday( &o_timestamp, NULL );
if( d_connection &&
d_connection->pack_message( len, o_timestamp, report_num_channels_m_id,
d_sender_id, msgbuf, class_of_service ) )
@@ -211,7 +211,7 @@ vrpn_Analog_Output_Remote::vrpn_Analog_Output_Remote(const char* name, vrpn_Conn
for (i = 0; i < vrpn_CHANNEL_MAX; i++) {
o_channel[i] = 0;
}
- gettimeofday(&o_timestamp, NULL);
+ vrpn_gettimeofday(&o_timestamp, NULL);
// Register a handler for the report number of active channels message
if (register_autodeleted_handler(report_num_channels_m_id,
@@ -269,7 +269,7 @@ bool vrpn_Analog_Output_Remote::request_change_channel_value(unsigned int chan,
vrpn_int32 len;
- gettimeofday(&o_timestamp, NULL);
+ vrpn_gettimeofday(&o_timestamp, NULL);
len = encode_change_to(msgbuf, chan, val);
if (d_connection && d_connection->pack_message(len, o_timestamp,
request_m_id, d_sender_id, msgbuf,
@@ -292,7 +292,7 @@ bool vrpn_Analog_Output_Remote::request_change_channels(int num, vrpn_float64* v
char* msgbuf = (char*) fbuf;
vrpn_int32 len;
- gettimeofday(&o_timestamp, NULL);
+ vrpn_gettimeofday(&o_timestamp, NULL);
len = encode_change_channels_to(msgbuf, num, vals);
if( d_connection &&
d_connection->pack_message( len, o_timestamp,
View
6 vrpn_Analog_Radamec_SPI.C
@@ -326,7 +326,7 @@ int vrpn_Radamec_SPI::reset(void)
SPI_WARNING("reset complete (this is good)");
- gettimeofday(&timestamp, NULL); // Set watchdog now
+ vrpn_gettimeofday(&timestamp, NULL); // Set watchdog now
return 0;
}
@@ -386,7 +386,7 @@ int vrpn_Radamec_SPI::get_report(void)
// The time stored here is as close as possible to when the
// report was generated.
_bufcount = 1;
- gettimeofday(&timestamp, NULL);
+ vrpn_gettimeofday(&timestamp, NULL);
status = STATUS_READING;
#ifdef VERBOSE
printf("... Got the 1st char\n");
@@ -563,7 +563,7 @@ void vrpn_Radamec_SPI::mainloop()
while (get_report()) {}; // Keep getting reports so long as there are more
struct timeval current_time;
- gettimeofday(&current_time, NULL);
+ vrpn_gettimeofday(&current_time, NULL);
if ( duration(current_time,timestamp) > MAX_TIME_INTERVAL) {
sprintf(errmsg,"Timeout... current_time=%ld:%ld, timestamp=%ld:%ld",current_time.tv_sec, current_time.tv_usec, timestamp.tv_sec, timestamp.tv_usec);
SPI_ERROR(errmsg);
View
8 vrpn_BaseClass.C
@@ -532,7 +532,7 @@ void vrpn_BaseClassUnique::client_mainloop(void)
if (d_unanswered_ping) {
- gettimeofday(&now, NULL);
+ vrpn_gettimeofday(&now, NULL);
diff = vrpn_TimevalDiff(now, d_time_last_warned);
vrpn_TimevalNormalize(diff);
@@ -559,7 +559,7 @@ void vrpn_BaseClassUnique::client_mainloop(void)
void vrpn_BaseClassUnique::initiate_ping_cycle(void)
{
// Record when we sent the ping and say that we haven't gotten an answer
- gettimeofday(&d_time_first_ping, NULL);
+ vrpn_gettimeofday(&d_time_first_ping, NULL);
d_connection->pack_message(0, d_time_first_ping, d_ping_message_id, d_sender_id,
NULL, vrpn_CONNECTION_RELIABLE);
d_unanswered_ping = 1;
@@ -599,7 +599,7 @@ int vrpn_BaseClassUnique::handle_ping(void *userdata, vrpn_HANDLERPARAM)
vrpn_BaseClassUnique *me = (vrpn_BaseClassUnique *)userdata;
struct timeval now;
- gettimeofday(&now, NULL);
+ vrpn_gettimeofday(&now, NULL);
if (me->d_connection != NULL) {
me->d_connection->pack_message(0, now, me->d_pong_message_id, me->d_sender_id, NULL, vrpn_CONNECTION_RELIABLE);
}
@@ -621,7 +621,7 @@ int vrpn_BaseClassUnique::handle_connection_dropped(void *userdata, vrpn_HANDLER
return 0;
}
- gettimeofday(&now, NULL);
+ vrpn_gettimeofday(&now, NULL);
if (me->d_connection != NULL) {
me->initiate_ping_cycle();
}
View
16 vrpn_Button.C
@@ -407,7 +407,7 @@ void vrpn_Button_Example_Server::mainloop()
// IN A REAL SERVER, this check would not be done; although the
// time of the report would be updated to the current time so
// that the correct timestamp would be issued on the report.
- gettimeofday(&current_time, NULL);
+ vrpn_gettimeofday(&current_time, NULL);
if ( duration(current_time,timestamp) >= 1000000.0/_update_rate) {
// Update the time
@@ -515,7 +515,7 @@ vrpn_Button_Parallel::vrpn_Button_Parallel(const char *name,
}
status = BUTTON_READY;
- gettimeofday(&timestamp, NULL);
+ vrpn_gettimeofday(&timestamp, NULL);
#endif
}
@@ -611,7 +611,7 @@ void vrpn_Button_Python::read(void)
buttons[3] = ((status_register[0] & PORT_ERROR) == 0);
buttons[4] = ((status_register[0] & PORT_ACK) == 0);
- gettimeofday(&timestamp, NULL);
+ vrpn_gettimeofday(&timestamp, NULL);
}
@@ -638,7 +638,7 @@ vrpn_Button_Filter(name, c)
// Reset the tracker and find out what time it is
status = BUTTON_READY;
- gettimeofday(&timestamp, NULL);
+ vrpn_gettimeofday(&timestamp, NULL);
}
vrpn_Button_Serial::~vrpn_Button_Serial() {
@@ -669,7 +669,7 @@ vrpn_Button_PinchGlove::vrpn_Button_PinchGlove(const char* name, vrpn_Connection
buttons[i] = lastbuttons[i] = VRPN_BUTTON_OFF;
// Reset the tracker and find out what time it is
- gettimeofday(&timestamp, NULL);
+ vrpn_gettimeofday(&timestamp, NULL);
}
void vrpn_Button_PinchGlove::mainloop()
@@ -755,7 +755,7 @@ void vrpn_Button_PinchGlove::read()
} // else
} // while (buffer[0] != PG_END_BYTE )
- gettimeofday(&timestamp, NULL);
+ vrpn_gettimeofday(&timestamp, NULL);
return;
}
@@ -835,7 +835,7 @@ vrpn_Button_Remote::vrpn_Button_Remote(const char *name, vrpn_Connection *cn):
for (i = 0; i < num_buttons; i++) {
buttons[i] = lastbuttons[i] = 0;
}
- gettimeofday(&timestamp, NULL);
+ vrpn_gettimeofday(&timestamp, NULL);
}
// virtual
@@ -1031,7 +1031,7 @@ vrpn_Button_SerialMouse::vrpn_Button_SerialMouse(const char *name,vrpn_Connectio
// Say we are ready and find out what time it is
status = BUTTON_READY;
- gettimeofday(&timestamp, NULL);
+ vrpn_gettimeofday(&timestamp, NULL);
}
void vrpn_Button_SerialMouse::mainloop()
View
6 vrpn_CerealBox.C
@@ -240,7 +240,7 @@ int vrpn_CerealBox::reset(void)
_expected_chars = 2 + 2*_numchannels + _numencoders*4 +
((_numbuttons+7) / 8) * 2;
- gettimeofday(&timestamp, NULL); // Set watchdog now
+ vrpn_gettimeofday(&timestamp, NULL); // Set watchdog now
return 0;
}
@@ -291,7 +291,7 @@ int vrpn_CerealBox::get_report(void)
// The time stored here is as close as possible to when the
// report was generated.
_bufcount = 1;
- gettimeofday(&timestamp, NULL);
+ vrpn_gettimeofday(&timestamp, NULL);
status = STATUS_READING;
#ifdef VERBOSE
printf("... Got the 1st char\n");
@@ -485,7 +485,7 @@ void vrpn_CerealBox::mainloop()
// if there is a report ready (ie, if THIS device is still operating).
while (get_report()) {}; // Keep getting reports as long as they come
struct timeval current_time;
- gettimeofday(&current_time, NULL);
+ vrpn_gettimeofday(&current_time, NULL);
if ( duration(current_time,timestamp) > MAX_TIME_INTERVAL) {
fprintf(stderr,"CerealBox failed to read... current_time=%ld:%ld, timestamp=%ld:%ld\n",current_time.tv_sec, current_time.tv_usec, timestamp.tv_sec, timestamp.tv_usec);
send_text_message("Too long since last report, resetting", current_time, vrpn_TEXT_ERROR);
View
22 vrpn_Clock.C
@@ -36,9 +36,9 @@ vrpn_Clock::vrpn_Clock(const char * name, vrpn_Connection *c) :
{
vrpn_BaseClass::init();
- // need to init gettimeofday for the pc
+ // need to init vrpn_gettimeofday for the pc
struct timeval tv;
- gettimeofday(&tv, NULL);
+ vrpn_gettimeofday(&tv, NULL);
}
int vrpn_Clock::register_senders(void)
@@ -140,7 +140,7 @@ int vrpn_Clock_Server::clockQueryHandler(void *userdata, vrpn_HANDLERPARAM p) {
return -1;
}
- gettimeofday(&now,NULL);
+ vrpn_gettimeofday(&now,NULL);
// printTime("server rep ", now);
int cLen = me->encode_to( rgch, now, p.msg_time, p.payload_len, p.buffer );
me->d_connection->pack_message(cLen, now,
@@ -237,7 +237,7 @@ vrpn_Clock_Remote::vrpn_Clock_Remote(const char * name, vrpn_float64 dFreq,
// establish unique id
struct timeval tv;
- gettimeofday(&tv, NULL);
+ vrpn_gettimeofday(&tv, NULL);
lUniqueID = (vrpn_int32)tv.tv_usec;
@@ -306,7 +306,7 @@ void vrpn_Clock_Remote::mainloop (const struct timeval *timeout)
// just a quick sync
// cerr << "QuickSync" << endl;
struct timeval tvNow;
- gettimeofday(&tvNow, NULL);
+ vrpn_gettimeofday(&tvNow, NULL);
// Check if we have passed the interval
if (vrpn_TimevalMsecs(vrpn_TimevalDiff(tvNow, tvQuickLastSync)) >=
@@ -320,7 +320,7 @@ void vrpn_Clock_Remote::mainloop (const struct timeval *timeout)
rgl[0]=htonl(CLOCK_VERSION);
rgl[1]=htonl(lUniqueID); // An easy, unique ID
rgl[2]=htonl((vrpn_int32)VRPN_CLOCK_QUICK_SYNC);
- gettimeofday(&tv, NULL);
+ vrpn_gettimeofday(&tv, NULL);
d_connection->pack_message(3*sizeof(vrpn_int32), tv, queryMsg_id,
clockClient_id, (char *)rgl,
vrpn_CONNECTION_RELIABLE);
@@ -375,7 +375,7 @@ void vrpn_Clock_Remote::mainloop (const struct timeval *timeout)
rgdTimes = new vrpn_float64[cQueries];
}
#endif
- gettimeofday( &tvCalib, NULL );
+ vrpn_gettimeofday( &tvCalib, NULL );
// do bounces for one second to calibrate the clocks
// while (cElapsedMsecs<=cCalibMsecs) {
@@ -406,7 +406,7 @@ void vrpn_Clock_Remote::mainloop (const struct timeval *timeout)
rgl[0]=htonl(CLOCK_VERSION);
rgl[1]=htonl(lUniqueID); // An easy, unique ID
rgl[2]=htonl((vrpn_int32)VRPN_CLOCK_FULL_SYNC);
- gettimeofday(&tv, NULL);
+ vrpn_gettimeofday(&tv, NULL);
d_connection->pack_message(3*sizeof(vrpn_int32), tv, queryMsg_id,
clockClient_id, (char *)rgl,
vrpn_CONNECTION_RELIABLE);
@@ -416,7 +416,7 @@ void vrpn_Clock_Remote::mainloop (const struct timeval *timeout)
// actually process the message and any callbacks from local
// or remote messages (just call the base mainloop)
d_connection->vrpn_Connection::mainloop();
- gettimeofday( &tvNow, NULL );
+ vrpn_gettimeofday( &tvNow, NULL );
cElapsedMsecs = (vrpn_int32) vrpn_TimevalMsecs(vrpn_TimevalDiff(tvNow, tvCalib));
}
// we don't care if we missed numerous replies, just make sure we had
@@ -655,7 +655,7 @@ int vrpn_Clock_Remote::fullSyncClockServerReplyHandler(void *userdata,
// get current local time
struct timeval tvLNow;
- gettimeofday(&tvLNow, NULL);
+ vrpn_gettimeofday(&tvLNow, NULL);
// all of the tv structs have an L (local) or R (remote) tag
vrpn_Clock_Remote *me = (vrpn_Clock_Remote *)userdata;
@@ -776,7 +776,7 @@ int vrpn_Clock_Remote::quickSyncClockServerReplyHandler(void *userdata,
// get current local time
struct timeval tvLNow;
- gettimeofday(&tvLNow, NULL);
+ vrpn_gettimeofday(&tvLNow, NULL);
// printTime("L now time", tvLNow);
View
14 vrpn_Configure.h
@@ -11,6 +11,7 @@
//--------------------------------------------------------//
// EDIT BELOW THIS LINE FOR NORMAL CONFIGURATION SETTING. //
//--------------------------------------------------------//
+//-----------------------
// Default port to listen on for a server. It used to be 4500
// up through version 6.03, but then all sorts of VPNs started
@@ -29,6 +30,17 @@
#define VRPN_NO_STREAMS
//-----------------------
+// Instructs VRPN to expose the vrpn_gettimeofday() function also
+// as gettimeofday() so that external programs can use it. This
+// has no effect on any system that already has gettimeofday()
+// defined, and is put here for Windows. This function should
+// not really be implemented within VRPN, but it was expedient to
+// include it when porting applications to Windows. Turn this
+// off if you have another implementation, or if you want to call
+// vrpn_gettimeofday() directly.
+#define VRPN_EXPORT_GETTIMEOFDAY
+
+//-----------------------
// Instructs VRPN to use phantom library to construct a unified
// server, using phantom as a common device, and phantom
// configuration in .cfg file.
@@ -56,7 +68,7 @@
// of the faster windows clock. The original one, made by Hans
// Weber, checks the clock rate to see how fast the performance
// clock runs (it takes a second to do this when the program
-// first calls gettimeofday()). The second version by Haris
+// first calls vrpn_gettimeofday()). The second version by Haris
// Fretzagias relies on the timing supplied by Windows. To use
// the second version, also define VRPN_WINDOWS_CLOCK_V2.
#define VRPN_UNSAFE_WINDOWS_CLOCK
View
34 vrpn_Connection.C
@@ -1660,7 +1660,6 @@ int vrpn_noint_select(int width, fd_set *readfds, fd_set *writefds,
struct timeval timeout2;
struct timeval *timeout2ptr;
struct timeval start, stop, now;
- struct timezone zone;
/* If the timeout parameter is non-NULL and non-zero, then we
* may have to adjust it due to an interrupt. In these cases,
@@ -1671,7 +1670,7 @@ int vrpn_noint_select(int width, fd_set *readfds, fd_set *writefds,
((timeout->tv_sec != 0) || (timeout->tv_usec != 0)) ) {
timeout2 = *timeout;
timeout2ptr = &timeout2;
- gettimeofday(&start, &zone); /* Find start time */
+ vrpn_gettimeofday(&start, NULL); /* Find start time */
//time_add(start,*timeout,stop); /* Find stop time */
stop = vrpn_TimevalSum(start, *timeout);/* Find stop time */
} else {
@@ -1707,7 +1706,7 @@ int vrpn_noint_select(int width, fd_set *readfds, fd_set *writefds,
((timeout->tv_sec != 0) || (timeout->tv_usec != 0))) {
/* Interrupt happened. Find new time timeout value */
- gettimeofday(&now, &zone);
+ vrpn_gettimeofday(&now, NULL);
if (vrpn_TimevalGreater(now, stop)) {/* Past stop time */
done = 1;
} else { /* Still time to go. */
@@ -1895,7 +1894,6 @@ int vrpn_noint_block_read_timeout(int infile, char buffer[],
struct timeval timeout2;
struct timeval *timeout2ptr;
struct timeval start, stop, now;
- struct timezone zone;
// TCH 4 Jan 2000 - hackish - Cygwin will block forever on a 0-length
// read(), and from the man pages this is close enough to in-spec that
@@ -1914,7 +1912,7 @@ int vrpn_noint_block_read_timeout(int infile, char buffer[],
((timeout->tv_sec != 0) || (timeout->tv_usec != 0)) ) {
timeout2 = *timeout;
timeout2ptr = &timeout2;
- gettimeofday(&start, &zone); /* Find start time */
+ vrpn_gettimeofday(&start, NULL); /* Find start time */
stop = vrpn_TimevalSum(start, *timeout);/* Find stop time */
} else {
timeout2ptr = timeout;
@@ -1948,7 +1946,7 @@ int vrpn_noint_block_read_timeout(int infile, char buffer[],
/* See what time it is now and how long we have to go */
if (timeout2ptr) {
- gettimeofday(&now, &zone);
+ vrpn_gettimeofday(&now, NULL);
if (vrpn_TimevalGreater(now, stop)) { /* Timeout! */
return sofar;
} else {
@@ -2929,7 +2927,7 @@ int vrpn_Endpoint::mainloop (timeval * timeout,
// If we don't wait a while between these we flood buffers and
// do BAD THINGS (TM).
- gettimeofday(&now, NULL);
+ vrpn_gettimeofday(&now, NULL);
if (now.tv_sec - last_UDP_lob.tv_sec >= 2) {
last_UDP_lob.tv_sec = now.tv_sec;
@@ -3188,7 +3186,7 @@ int vrpn_Endpoint::pack_udp_description (int portno) {
fprintf(stderr, "vrpn_Endpoint::pack_udp_description: "
"Packing UDP %s:%d\n", myIPchar, portno);
#endif
- gettimeofday(&now, NULL);
+ vrpn_gettimeofday(&now, NULL);
return pack_message(strlen(myIPchar) + 1, now,
vrpn_CONNECTION_UDP_DESCRIPTION,
@@ -3213,7 +3211,7 @@ int vrpn_Endpoint::pack_log_description (void) {
// and whose body holds the zero-terminated string name of the file
// to write to.
- gettimeofday(&now, NULL);
+ vrpn_gettimeofday(&now, NULL);
bpp = buf;
bp = &bpp;
vrpn_buffer(bp, &buflen, (vrpn_int32) strlen(d_remoteInLogName));
@@ -3565,7 +3563,7 @@ void vrpn_Endpoint::drop_connection (void) {
clearBuffers();
struct timeval now, adj_time;
- gettimeofday(&now, NULL);
+ vrpn_gettimeofday(&now, NULL);
// Adjust the time of this system message. Default adjustment is 0.
adj_time = vrpn_TimevalSum(now, d_controlMsgTimeOffset);
@@ -3830,7 +3828,7 @@ int vrpn_Endpoint::finish_new_connection_setup (void) {
// Message needs to be dispatched *locally only*, so we do_callbacks_for
// and never pack_message()
struct timeval now;
- gettimeofday(&now, NULL);
+ vrpn_gettimeofday(&now, NULL);
// Connection counter gives us a single point to count connections that
// actually make it to CONNECTED, not just constructed, so we send
@@ -4323,7 +4321,7 @@ int vrpn_Endpoint::pack_type_description (vrpn_int32 which) {
memcpy(buffer, &netlen, sizeof(netlen));
memcpy(&buffer[sizeof(len)], d_dispatcher->typeName(which),
(vrpn_int32) len);
- gettimeofday(&now,NULL);
+ vrpn_gettimeofday(&now,NULL);
return pack_message((vrpn_uint32) (len + sizeof(len)), now,
vrpn_CONNECTION_TYPE_DESCRIPTION, which, buffer,
@@ -4351,7 +4349,7 @@ int vrpn_Endpoint::pack_sender_description (vrpn_int32 which) {
memcpy(buffer, &netlen, sizeof(netlen));
memcpy(&buffer[sizeof(len)], d_dispatcher->senderName(which),
(vrpn_int32) len);
- gettimeofday(&now,NULL);
+ vrpn_gettimeofday(&now,NULL);
return pack_message((vrpn_uint32)(len + sizeof(len)), now,
vrpn_CONNECTION_SENDER_DESCRIPTION, which, buffer,
@@ -4359,7 +4357,7 @@ int vrpn_Endpoint::pack_sender_description (vrpn_int32 which) {
}
/** Set an offset that the endpoint should add to the timestamp it gets from
- gettimeofday before it sends drop connection system messages. Allows us to
+ vrpn_gettimeofday before it sends drop connection system messages. Allows us to
construct a log file with something other than wall-clock time for system
messages. I was having a problem with dropped connection, specifically, but
if other messages are a problem, it can be extended to those.
@@ -4710,7 +4708,7 @@ int vrpn_Connection::send_pending_reports (void) {
int vrpn_Connection::time_since_connection_open
(struct timeval * elapsed_time) {
struct timeval now;
- gettimeofday(&now, NULL);
+ vrpn_gettimeofday(&now, NULL);
*elapsed_time = vrpn_TimevalDiff(now, start_time);
return 0;
@@ -4768,7 +4766,7 @@ void vrpn_Connection::init (void) {
}
- gettimeofday(&start_time, NULL);
+ vrpn_gettimeofday(&start_time, NULL);
#ifdef VRPN_USE_WINSOCK_SOCKETS
@@ -5356,7 +5354,7 @@ vrpn_Connection::vrpn_Connection
}
// Lob a packet asking for a connection on that port.
- gettimeofday(&endpoint->last_UDP_lob, NULL);
+ vrpn_gettimeofday(&endpoint->last_UDP_lob, NULL);
if (vrpn_udp_request_lob_packet(endpoint->remote_machine_name,
endpoint->remote_UDP_port,
endpoint->d_tcpListenPort,
@@ -5883,7 +5881,7 @@ int vrpn_Synchronized_Connection::mainloop (const struct timeval * timeout)
if (connectionStatus == BROKEN) {
static struct timeval last_told = {0,0};
static struct timeval now;
- gettimeofday(&now, NULL);
+ vrpn_gettimeofday(&now, NULL);
if (now.tv_sec != last_told.tv_sec) {
fprintf(stderr, "vrpn_Synchronized_Connection::mainloop: Connection object is broken\n");
memcpy(&last_told, &now, sizeof(last_told));
View
4 vrpn_Dial.C
@@ -133,7 +133,7 @@ void vrpn_Dial_Example_Server::mainloop()
// IN A REAL SERVER, this check would not be done; although the
// time of the report would be updated to the current time so
// that the correct timestamp would be issued on the report.
- gettimeofday(&current_time, NULL);
+ vrpn_gettimeofday(&current_time, NULL);
if ( duration(current_time,timestamp) >= 1000000.0/_update_rate) {
// Update the time
@@ -185,7 +185,7 @@ vrpn_Dial_Remote::vrpn_Dial_Remote (const char * name,
for (i = 0; i < vrpn_DIAL_MAX; i++) {
dials[i] = 0.0;
}
- gettimeofday(&timestamp, NULL);
+ vrpn_gettimeofday(&timestamp, NULL);
}
vrpn_Dial_Remote::~vrpn_Dial_Remote()
View
12 vrpn_DirectXFFJoystick.C
@@ -96,7 +96,7 @@ vrpn_DirectXFFJoystick::vrpn_DirectXFFJoystick (const char * name, vrpn_Connecti
// Set the mode to reading. Set time to zero, so we'll try to read
_status = STATUS_READING;
- gettimeofday(&_timestamp, NULL);
+ vrpn_gettimeofday(&_timestamp, NULL);
}
vrpn_DirectXFFJoystick::~vrpn_DirectXFFJoystick()
@@ -369,7 +369,7 @@ int vrpn_DirectXFFJoystick::get_report(void)
{
static struct timeval forcetime = {0,0};
struct timeval now;
- gettimeofday(&now, NULL);
+ vrpn_gettimeofday(&now, NULL);
if (duration(now, forcetime) >= 1000000.0 / _force_rate) {
send_normalized_force(_fX, _fY);
forcetime = now;
@@ -378,7 +378,7 @@ int vrpn_DirectXFFJoystick::get_report(void)
// If it is not time for the next read, just return
struct timeval reporttime;
- gettimeofday(&reporttime, NULL);
+ vrpn_gettimeofday(&reporttime, NULL);
if (duration(reporttime, _timestamp) < 1000000.0 / _read_rate) {
return 0;
}
@@ -399,9 +399,9 @@ int vrpn_DirectXFFJoystick::get_report(void)
hr = _Joystick->Acquire();
if ( hr == DIERR_INPUTLOST ) {
struct timeval resettime;
- gettimeofday(&resettime, NULL);
+ vrpn_gettimeofday(&resettime, NULL);
while ( ( hr == DIERR_INPUTLOST) && (duration(resettime, reporttime) <= MAX_TIME_INTERVAL) ) {
- gettimeofday(&resettime, NULL);
+ vrpn_gettimeofday(&resettime, NULL);
hr = _Joystick->Acquire();
}
if (hr == DIERR_INPUTLOST) {
@@ -565,7 +565,7 @@ void vrpn_DirectXFFJoystick::mainloop()
{
static struct timeval last_report = {0,0};
struct timeval now;
- gettimeofday(&now, NULL);
+ vrpn_gettimeofday(&now, NULL);
if (duration(now, last_report) > MAX_TIME_INTERVAL) {
send_text_message("Cannot talk to joystick", now, vrpn_TEXT_ERROR);
last_report = now;
View
4 vrpn_Dyna.C
@@ -138,7 +138,7 @@ void vrpn_Tracker_Dyna::reset() {
vrpn_write_characters(serial_fd, (const unsigned char *)"V", 1);
//T_PDYN_C_CONTINUOUS = "V"
sleep(1);
- //gettimeofday(&timestamp, NULL); // Set watchdog now;
+ //vrpn_gettimeofday(&timestamp, NULL); // Set watchdog now;
timestamp.tv_sec = -1;
status = vrpn_TRACKER_SYNCING; // We are trying for a new reading;
return;
@@ -153,7 +153,7 @@ int vrpn_Tracker_Dyna::get_report(void) {
(buffer[0] & llll_OOOO) != lOOO_OOOO) {
return 0;
}
- gettimeofday(&timestamp, NULL);
+ vrpn_gettimeofday(&timestamp, NULL);
status = vrpn_TRACKER_PARTIAL;
bufcount= ret;
}
View
18 vrpn_FileConnection.C
@@ -289,7 +289,7 @@ void vrpn_File_Connection::FileTime_Accumulator::set_replay_rate(
vrpn_float32 new_rate)
{
timeval now_time;
- gettimeofday(&now_time, NULL);
+ vrpn_gettimeofday(&now_time, NULL);
accumulate_to( now_time );
d_replay_rate = new_rate;
@@ -341,12 +341,12 @@ void vrpn_File_Connection::FileTime_Accumulator::reset_at_time(
// represents the amount of time elapsed sice d_last_time was last set.
//
// set_replay_rate will do sample-and-hold integration over the window
-// from d_last_time to the result of gettimeofday(), and it will
+// from d_last_time to the result of vrpn_gettimeofday(), and it will
// accumulate the result into d_virtual_time_elapsed_since_last_event.
-// then it will set d_last_time to the result of gettimeofday().
+// then it will set d_last_time to the result of vrpn_gettimeofday().
//
// mainloop will also do sample-and-hold integration over the window
-// [d_last_time:gettimeofday()], and accumulate the result into
+// [d_last_time:vrpn_gettimeofday()], and accumulate the result into
// d_virtual_time_elapsed_since_last_event. Then it will compute end_time
// by adding d_time and d_virtual_time_elapsed_since_last_event. iff an
// event is played from the file, d_last_time will be set to now_time and
@@ -360,7 +360,7 @@ int vrpn_File_Connection::mainloop( const timeval * /*timeout*/ )
// XXX timeout ignored for now, needs to be added
timeval now_time;
- gettimeofday(&now_time, NULL);
+ vrpn_gettimeofday(&now_time, NULL);
if ((d_last_time.tv_sec == 0) && (d_last_time.tv_usec == 0)) {
// If first iteration, consider 0 time elapsed
@@ -636,7 +636,7 @@ int vrpn_File_Connection::playone_to_filetime( timeval end_filetime )
// or do we mark them with the time they were played back?
// Maybe this should be switchable, but the latter is what
// I need yesterday.
- gettimeofday(&now, NULL);
+ vrpn_gettimeofday(&now, NULL);
retval = endpoint->d_inLog->logIncomingMessage
(header.payload_len, now, header.type,
header.sender, header.buffer);
@@ -731,7 +731,7 @@ timeval vrpn_File_Connection::get_length()
timeval stop;
do {
stop = d_logHead->data.msg_time;
- } while (advance_currentLogEntry == 0);
+ } while (advance_currentLogEntry() == 0);
len = vrpn_TimevalDiff(stop, start);
}
@@ -763,7 +763,7 @@ timeval vrpn_File_Connection::get_lowest_user_timestamp()
vrpn_TimevalGreater(low, d_currentLogEntry->data.msg_time)) {
low = d_currentLogEntry->data.msg_time;
}
- } while (advance_currentLogEntry == 0);
+ } while (advance_currentLogEntry() == 0);
// We have our value. Set it and go back where
// we came from, but don't play the records along
@@ -850,7 +850,7 @@ int vrpn_File_Connection::read_entry (void)
if (!d_file) {
static struct timeval last_told = {0,0};
static struct timeval now;
- gettimeofday(&now, NULL);
+ vrpn_gettimeofday(&now, NULL);
if (now.tv_sec != last_told.tv_sec) {
fprintf(stderr, "vrpn_File_Connection::read_entry: no open file\n");
memcpy(&last_told, &now, sizeof(last_told));
View
6 vrpn_FileController.C
@@ -34,7 +34,7 @@ void vrpn_File_Controller::set_replay_rate (vrpn_float32 rate) {
vrpn_float32 temp = rate;
vrpn_int32 netValue = htonl(*(vrpn_int32 *) &temp);
- gettimeofday(&now, NULL);
+ vrpn_gettimeofday(&now, NULL);
d_connection->pack_message(sizeof(netValue), now,
d_set_replay_rate_type, d_myId, (const char *) &netValue,
vrpn_CONNECTION_RELIABLE); // | vrpn_CONNECTION_LOCAL_ONLY
@@ -43,7 +43,7 @@ void vrpn_File_Controller::set_replay_rate (vrpn_float32 rate) {
void vrpn_File_Controller::reset (void) {
struct timeval now;
- gettimeofday(&now, NULL);
+ vrpn_gettimeofday(&now, NULL);
d_connection->pack_message(0, now,
d_reset_type, d_myId, NULL,
vrpn_CONNECTION_RELIABLE); // | vrpn_CONNECTION_LOCAL_ONLY
@@ -52,7 +52,7 @@ void vrpn_File_Controller::reset (void) {
void vrpn_File_Controller::play_to_time (struct timeval t) {
struct timeval now;
- gettimeofday(&now, NULL);
+ vrpn_gettimeofday(&now, NULL);
d_connection->pack_message(sizeof(struct timeval), now,
d_play_to_time_type, d_myId, (const char *) &t,
vrpn_CONNECTION_RELIABLE); // | vrpn_CONNECTION_LOCAL_ONLY
View
8 vrpn_Flock.C
@@ -520,7 +520,7 @@ void vrpn_Tracker_Flock::reset()
fprintf(stderr,"\nvrpn_Tracker_Flock: done with reset ... running.\n");
- gettimeofday(&timestamp, NULL); // Set watchdog now
+ vrpn_gettimeofday(&timestamp, NULL); // Set watchdog now
status = vrpn_TRACKER_SYNCING; // We're trying for a new reading
}
@@ -568,7 +568,7 @@ int vrpn_Tracker_Flock::get_report(void)
// Got the first character of a report -- go into PARTIAL mode
// and say that we got one character at this time.
bufcount = 1;
- gettimeofday(&timestamp, NULL);
+ vrpn_gettimeofday(&timestamp, NULL);
status = vrpn_TRACKER_PARTIAL;
}
@@ -682,7 +682,7 @@ if (vrpn_write_characters(serial_fd, (const unsigned char *) &chPoint, 1 )!=1) {
status = vrpn_TRACKER_FAIL;\
return;\
} \
-gettimeofday(&timestamp, NULL);\
+vrpn_gettimeofday(&timestamp, NULL);\
}
// max time between start of a report and the finish (or time to
@@ -717,7 +717,7 @@ void vrpn_Tracker_Flock::send_report(void) {
struct timeval tvNow;
// get curr time
- gettimeofday(&tvNow, NULL);
+ vrpn_gettimeofday(&tvNow, NULL);
if (fFirstStatusReport) {
// print a status message in cStatusInterval seconds
View
6 vrpn_Flock_Parallel.C
@@ -255,7 +255,7 @@ if (vrpn_write_characters(serial_fd, (const unsigned char *) &chPoint, 1 )!=1) {
status = vrpn_TRACKER_FAIL;\
return;\
} \
-gettimeofday(&timestamp, NULL);\
+vrpn_gettimeofday(&timestamp, NULL);\
}
@@ -324,7 +324,7 @@ void vrpn_Tracker_Flock_Parallel_Slave::reset()
fprintf(stderr,"\nvrpn_Tracker_Flock_Parallel_Slave %d: "
"done with reset ... running.\n", d_sensor);
- gettimeofday(&timestamp, NULL); // Set watchdog now
+ vrpn_gettimeofday(&timestamp, NULL); // Set watchdog now
status = vrpn_TRACKER_SYNCING; // We're trying for a new reading
}
@@ -362,7 +362,7 @@ void vrpn_Tracker_Flock_Parallel_Slave::mainloop()
send_report();
}
struct timeval current_time;
- gettimeofday(&current_time, NULL);
+ vrpn_gettimeofday(&current_time, NULL);
if ( duration(current_time,timestamp) > MAX_TIME_INTERVAL) {
fprintf(stderr,"Tracker failed to read... current_time=%ld:%ld, timestamp=%ld:%ld\n",current_time.tv_sec, current_time.tv_usec, timestamp.tv_sec, timestamp.tv_usec);
send_text_message("Too long since last report, resetting", current_time, vrpn_TEXT_ERROR);
View
38 vrpn_ForceDevice.C
@@ -861,7 +861,7 @@ void vrpn_ForceDevice::sendError(int error_code) {
vrpn_int32 len;
struct timeval current_time;
- gettimeofday(&current_time, NULL);
+ vrpn_gettimeofday(&current_time, NULL);
timestamp.tv_sec = current_time.tv_sec;
timestamp.tv_usec = current_time.tv_usec;
@@ -1186,7 +1186,7 @@ vrpn_ForceDevice_Remote::vrpn_ForceDevice_Remote(const char *name, vrpn_Connecti
}
// Find out what time it is and put this into the timestamp
- gettimeofday(&timestamp, NULL);
+ vrpn_gettimeofday(&timestamp, NULL);
}
// virtual
@@ -1221,7 +1221,7 @@ void vrpn_ForceDevice_Remote::sendSurface(void)
vrpn_int32 len;
struct timeval current_time;
- gettimeofday(&current_time, NULL);
+ vrpn_gettimeofday(&current_time, NULL);
timestamp.tv_sec = current_time.tv_sec;
timestamp.tv_usec = current_time.tv_usec;
@@ -1253,7 +1253,7 @@ void vrpn_ForceDevice_Remote::startSurface(void)
vrpn_int32 len;
struct timeval current_time;
- gettimeofday(&current_time, NULL);
+ vrpn_gettimeofday(&current_time, NULL);
timestamp.tv_sec = current_time.tv_sec;
timestamp.tv_usec = current_time.tv_usec;
@@ -1274,7 +1274,7 @@ void vrpn_ForceDevice_Remote::stopSurface(void)
vrpn_int32 len;
struct timeval current_time;
- gettimeofday(&current_time, NULL);
+ vrpn_gettimeofday(&current_time, NULL);
timestamp.tv_sec = current_time.tv_sec;
timestamp.tv_usec = current_time.tv_usec;
@@ -1297,7 +1297,7 @@ void vrpn_ForceDevice_Remote::setVertex(vrpn_int32 vertNum,vrpn_float32 x,vrpn_f
vrpn_int32 len;
struct timeval current_time;
- gettimeofday(&current_time, NULL);
+ vrpn_gettimeofday(&current_time, NULL);
timestamp.tv_sec = current_time.tv_sec;
timestamp.tv_usec = current_time.tv_usec;
@@ -1316,7 +1316,7 @@ void vrpn_ForceDevice_Remote::setNormal(vrpn_int32 normNum,vrpn_float32 x,vrpn_f
vrpn_int32 len;
struct timeval current_time;
- gettimeofday(&current_time, NULL);
+ vrpn_gettimeofday(&current_time, NULL);
timestamp.tv_sec = current_time.tv_sec;
timestamp.tv_usec = current_time.tv_usec;
@@ -1337,7 +1337,7 @@ void vrpn_ForceDevice_Remote::setTriangle(vrpn_int32 triNum,
vrpn_int32 len;
struct timeval current_time;
- gettimeofday(&current_time, NULL);
+ vrpn_gettimeofday(&current_time, NULL);
timestamp.tv_sec = current_time.tv_sec;
timestamp.tv_usec = current_time.tv_usec;
@@ -1357,7 +1357,7 @@ void vrpn_ForceDevice_Remote::removeTriangle(vrpn_int32 triNum){
vrpn_int32 len;
struct timeval current_time;
- gettimeofday(&current_time, NULL);
+ vrpn_gettimeofday(&current_time, NULL);
timestamp.tv_sec = current_time.tv_sec;
timestamp.tv_usec = current_time.tv_usec;
@@ -1377,7 +1377,7 @@ void vrpn_ForceDevice_Remote::updateTrimeshChanges(){
vrpn_int32 len;
struct timeval current_time;
- gettimeofday(&current_time, NULL);
+ vrpn_gettimeofday(&current_time, NULL);
timestamp.tv_sec = current_time.tv_sec;
timestamp.tv_usec = current_time.tv_usec;
@@ -1398,7 +1398,7 @@ void vrpn_ForceDevice_Remote::setTrimeshTransform(vrpn_float32 homMatrix[16]){
vrpn_int32 len;
struct timeval current_time;
- gettimeofday(&current_time, NULL);
+ vrpn_gettimeofday(&current_time, NULL);
timestamp.tv_sec = current_time.tv_sec;
timestamp.tv_usec = current_time.tv_usec;
@@ -1418,7 +1418,7 @@ void vrpn_ForceDevice_Remote::clearTrimesh(void){
vrpn_int32 len=0;
struct timeval current_time;
- gettimeofday(&current_time, NULL);
+ vrpn_gettimeofday(&current_time, NULL);
timestamp.tv_sec = current_time.tv_sec;
timestamp.tv_usec = current_time.tv_usec;
@@ -1437,7 +1437,7 @@ void vrpn_ForceDevice_Remote::useHcollide(void){
vrpn_int32 len;
struct timeval current_time;
- gettimeofday(&current_time, NULL);
+ vrpn_gettimeofday(&current_time, NULL);
timestamp.tv_sec = current_time.tv_sec;
timestamp.tv_usec = current_time.tv_usec;
@@ -1456,7 +1456,7 @@ void vrpn_ForceDevice_Remote::useGhost(void){
vrpn_int32 len;
struct timeval current_time;
- gettimeofday(&current_time, NULL);
+ vrpn_gettimeofday(&current_time, NULL);
timestamp.tv_sec = current_time.tv_sec;
timestamp.tv_usec = current_time.tv_usec;
@@ -1477,7 +1477,7 @@ void vrpn_ForceDevice_Remote::startEffect(void)
vrpn_int32 len;
struct timeval current_time;
- gettimeofday(&current_time, NULL);
+ vrpn_gettimeofday(&current_time, NULL);
timestamp.tv_sec = current_time.tv_sec;
timestamp.tv_usec = current_time.tv_usec;
@@ -1497,7 +1497,7 @@ void vrpn_ForceDevice_Remote::stopEffect(void)
vrpn_int32 len;
struct timeval current_time;
- gettimeofday(&current_time, NULL);
+ vrpn_gettimeofday(&current_time, NULL);
timestamp.tv_sec = current_time.tv_sec;
timestamp.tv_usec = current_time.tv_usec;
@@ -1640,7 +1640,7 @@ void vrpn_ForceDevice_Remote::sendForceField
vrpn_int32 len;
struct timeval current_time;
- gettimeofday(&current_time, NULL);
+ vrpn_gettimeofday(&current_time, NULL);
timestamp.tv_sec = current_time.tv_sec;
timestamp.tv_usec = current_time.tv_usec;
@@ -1666,7 +1666,7 @@ void vrpn_ForceDevice_Remote::stopForceField (void)
vrpn_int32 len;
struct timeval current_time;
- gettimeofday(&current_time, NULL);
+ vrpn_gettimeofday(&current_time, NULL);
timestamp.tv_sec = current_time.tv_sec;
timestamp.tv_usec = current_time.tv_usec;
@@ -1936,7 +1936,7 @@ void vrpn_ForceDevice_Remote::send (const char * msgbuf, vrpn_int32 len,
vrpn_int32 type) {
struct timeval now;
- gettimeofday(&now, NULL);
+ vrpn_gettimeofday(&now, NULL);
timestamp.tv_sec = now.tv_sec;
timestamp.tv_usec = now.tv_usec;
View
4 vrpn_ForwarderController.C
@@ -273,7 +273,7 @@ void vrpn_Forwarder_Controller::start_remote_forwarding (vrpn_int32 remote_port)
char * buffer;
vrpn_int32 length;
- gettimeofday(&now, NULL);
+ vrpn_gettimeofday(&now, NULL);
buffer = encode_start_remote_forwarding(&length, remote_port);
if (!buffer)
@@ -291,7 +291,7 @@ void vrpn_Forwarder_Controller::forward_message_type
char * buffer;
vrpn_int32 length;
- gettimeofday(&now, NULL);
+ vrpn_gettimeofday(&now, NULL);
buffer = encode_forward_message_type(&length, remote_port, service_name,
message_type);
View
6 vrpn_GlobalHapticsOrb.C
@@ -134,7 +134,7 @@ int vrpn_GlobalHapticsOrb::reset(void)
// which is just 1 for the Orb.
d_expected_chars = 1;
- gettimeofday(&d_timestamp, NULL); // Set watchdog now
+ vrpn_gettimeofday(&d_timestamp, NULL); // Set watchdog now
send_text_message("vrpn_GlobalHapticsOrb::reset(): Reset complete (this is good)", d_timestamp, vrpn_TEXT_ERROR);
@@ -170,7 +170,7 @@ int vrpn_GlobalHapticsOrb::get_report(void)
}
d_bufcount = 1;
- gettimeofday(&d_timestamp, NULL);
+ vrpn_gettimeofday(&d_timestamp, NULL);
// Respond to the command, ignore it, or throw an error if it is
// one we don't know how to deal with.
@@ -331,7 +331,7 @@ void vrpn_GlobalHapticsOrb::mainloop()
// if there is a report ready (ie, if THIS device is still operating).
while (get_report()) {}; // Keep getting reports as long as they come
struct timeval current_time;
- gettimeofday(&current_time, NULL);
+ vrpn_gettimeofday(&current_time, NULL);
// If we haven't heard in a while (this can be normal), send a reset
// request to the device -- this will cause a response of 0xfc, which
View
14 vrpn_ImmersionBox.C
@@ -43,10 +43,10 @@ static void pause (double delay) {
unsigned long interval = (long) floor(1000000.0 * delay);
struct timeval start, now;
- gettimeofday (&start, NULL);
+ vrpn_gettimeofday (&start, NULL);
do {
- gettimeofday (&now, NULL);
+ vrpn_gettimeofday (&now, NULL);
} while (duration(now, start) < interval);
}
@@ -230,7 +230,7 @@ int vrpn_ImmersionBox::reset(void)
cout << "ImmersionBox reset complete." << endl;
status = STATUS_SYNCING;
- gettimeofday(&timestamp, NULL); // Set watchdog now
+ vrpn_gettimeofday(&timestamp, NULL); // Set watchdog now
return 0;
}
@@ -318,7 +318,7 @@ int vrpn_ImmersionBox::get_report(void)
}
report_changes();
- gettimeofday(&timestamp, NULL); // Set watchdog now
+ vrpn_gettimeofday(&timestamp, NULL); // Set watchdog now
return 1;
}
@@ -371,7 +371,7 @@ void vrpn_ImmersionBox::mainloop(void)
// if there is a report ready (ie, if THIS device is still operating).
while (get_report()) {}; // Get multiple reports if available
struct timeval current_time;
- gettimeofday(&current_time, NULL);
+ vrpn_gettimeofday(&current_time, NULL);
if ( duration(current_time,timestamp) > MAX_TIME_INTERVAL) {
fprintf(stderr,"Tracker failed to read... current_time=%ld:%ld, timestamp=%ld:%ld\n",current_time.tv_sec, current_time.tv_usec, timestamp.tv_sec, timestamp.tv_usec);
send_text_message("Too long since last report, resetting", current_time, vrpn_TEXT_ERROR);
@@ -442,7 +442,7 @@ int vrpn_ImmersionBox::syncBaudrate (double seconds) {
unsigned long maxDelay = 1000000L * (long) seconds;
struct timeval start_time;
- gettimeofday(&start_time, NULL);
+ vrpn_gettimeofday(&start_time, NULL);
int loggedOn = 0;
unsigned char responseString[8];
@@ -457,7 +457,7 @@ int vrpn_ImmersionBox::syncBaudrate (double seconds) {
while (!loggedOn) {
struct timeval current_time;
- gettimeofday(&current_time, NULL);
+ vrpn_gettimeofday(&current_time, NULL);
if (duration(current_time, start_time) > maxDelay ) {
// if we've timed out, go back unhappy
cout << "vrpn_ImmersionBox::syncBaudrate timeout expired: " << seconds
View
5 vrpn_Joylin.C
@@ -56,7 +56,6 @@ vrpn_Joylin::vrpn_Joylin(char * name,
void vrpn_Joylin::mainloop(void) {
struct timeval zerotime;
- struct timezone zone;
fd_set fdset;
struct js_event js;
int i;
@@ -79,11 +78,11 @@ void vrpn_Joylin::mainloop(void) {
}
switch(js.type & ~JS_EVENT_INIT) {
case JS_EVENT_BUTTON:
- gettimeofday((timeval *)&vrpn_Button::timestamp, &zone);
+ vrpn_gettimeofday((timeval *)&vrpn_Button::timestamp, NULL);
buttons[js.number] = js.value;
break;
case JS_EVENT_AXIS:
- gettimeofday((timeval *)&vrpn_Analog::timestamp, &zone);
+ vrpn_gettimeofday((timeval *)&vrpn_Analog::timestamp, NULL);
channel[js.number] = js.value / 32767.0; /* FIX LATER */
break;
}
View
6 vrpn_Joywin32.C
@@ -140,7 +140,7 @@ vrpn_Joywin32::vrpn_Joywin32 (const char * name, vrpn_Connection * c, vrpn_uint8
// Set the mode to reading. Set time to zero, so we'll try to read
_status = STATUS_READING;
- gettimeofday(&_timestamp, NULL);
+ vrpn_gettimeofday(&_timestamp, NULL);
}
@@ -165,7 +165,7 @@ int vrpn_Joywin32::get_report(void)
{
// If it is not time for the next read, just return
struct timeval reporttime;
- gettimeofday(&reporttime, NULL);
+ vrpn_gettimeofday(&reporttime, NULL);
if (duration(reporttime, _timestamp) < 1000000.0 / _read_rate) {
return 0;
}
@@ -368,7 +368,7 @@ void vrpn_Joywin32::mainloop()
{
static struct timeval last_report = {0,0};
struct timeval now;
- gettimeofday(&now, NULL);
+ vrpn_gettimeofday(&now, NULL);
if (duration(now, last_report) > MAX_TIME_INTERVAL) {
send_text_message("Cannot talk to joystick", now, vrpn_TEXT_ERROR);
last_report = now;
View
6 vrpn_Magellan.C
@@ -136,7 +136,7 @@ int vrpn_Magellan::reset(void)
ret = vrpn_read_available_characters(serial_fd, inbuf, strlen(expect_back), &timeout);
inbuf[strlen(expect_back)] = 0; // Make sure string is NULL-terminated
- gettimeofday(&now, NULL);
+ vrpn_gettimeofday(&now, NULL);
if (ret < 0) {
send_text_message("vrpn_Magellan reset: Error reading from device", now);
return -1;
@@ -164,7 +164,7 @@ int vrpn_Magellan::reset(void)
// We're now waiting for a response from the box
status = STATUS_SYNCING;
- gettimeofday(&timestamp, NULL); // Set watchdog now
+ vrpn_gettimeofday(&timestamp, NULL); // Set watchdog now
return 0;
}
@@ -233,7 +233,7 @@ int vrpn_Magellan::get_report(void)
// The time stored here is as close as possible to when the
// report was generated.
_bufcount = 1;
- gettimeofday(&timestamp, NULL);
+ vrpn_gettimeofday(&timestamp, NULL);
status = STATUS_READING;
#ifdef VERBOSE
printf("... Got the 1st char\n");
View
22 vrpn_Mutex.C
@@ -169,7 +169,7 @@ void vrpn_Mutex::sendRequest (vrpn_int32 index) {
vrpn_int32 bl = 32;
if (!d_connection) return;
- gettimeofday(&now, NULL);
+ vrpn_gettimeofday(&now, NULL);
vrpn_buffer(&b, &bl, index);
d_connection->pack_message(32 - bl, now,
d_requestMutex_type, d_myId, buffer,
@@ -181,7 +181,7 @@ void vrpn_Mutex::sendRelease (void) {
if (!d_connection) return;
- gettimeofday(&now, NULL);
+ vrpn_gettimeofday(&now, NULL);
d_connection->pack_message(0, now,
d_release_type, d_myId, NULL,
vrpn_CONNECTION_RELIABLE);
@@ -192,7 +192,7 @@ void vrpn_Mutex::sendReleaseNotification (void) {
timeval now;
if (!d_connection) return;
- gettimeofday(&now, NULL);
+ vrpn_gettimeofday(&now, NULL);
d_connection->pack_message(0, now,
d_releaseNotification_type, d_myId, NULL,
vrpn_CONNECTION_RELIABLE);
@@ -206,7 +206,7 @@ void vrpn_Mutex::sendGrantRequest (vrpn_int32 index) {
vrpn_int32 bl = 32;
if (!d_connection) return;
- gettimeofday(&now, NULL);
+ vrpn_gettimeofday(&now, NULL);
vrpn_buffer(&b, &bl, index);
d_connection->pack_message(32 - bl, now,
d_grantRequest_type, d_myId, buffer,
@@ -221,7 +221,7 @@ void vrpn_Mutex::sendDenyRequest (vrpn_int32 index) {
vrpn_int32 bl = 32;
if (!d_connection) return;
- gettimeofday(&now, NULL);
+ vrpn_gettimeofday(&now, NULL);
vrpn_buffer(&b, &bl, index);
d_connection->pack_message(32 - bl, now,
d_denyRequest_type, d_myId, buffer,
@@ -339,7 +339,7 @@ int vrpn_Mutex_Server::handle_requestIndex (void *userdata,
#endif
if (me->d_connection) {
- gettimeofday(&now, NULL);
+ vrpn_gettimeofday(&now, NULL);
// echo back whatever the client gave us as a unique identifier
vrpn_buffer(&b, &bl, p.buffer, p.payload_len);
vrpn_buffer(&b, &bl, (me->d_remoteIndex));
@@ -461,7 +461,7 @@ void vrpn_Mutex_Remote::requestIndex (void) {
#ifdef VERBOSE
printf("requesting index for %lu, %d\n", ip_addr, pid);
#endif
- gettimeofday(&now, NULL);
+ vrpn_gettimeofday(&now, NULL);
d_connection->pack_message(buflen, now,
d_requestIndex_type, d_myId,
buf,
@@ -1264,7 +1264,7 @@ void vrpn_PeerMutex::sendRequest (vrpn_Connection * c) {
char * b = buffer;
vrpn_int32 bl = 32;
- gettimeofday(&now, NULL);
+ vrpn_gettimeofday(&now, NULL);
vrpn_buffer(&b, &bl, d_myIP);
vrpn_buffer(&b, &bl, d_myPort);
c->pack_message(32 - bl, now,
@@ -1279,7 +1279,7 @@ void vrpn_PeerMutex::sendRelease (vrpn_Connection * c) {
char * b = buffer;
vrpn_int32 bl = 32;
- gettimeofday(&now, NULL);
+ vrpn_gettimeofday(&now, NULL);
vrpn_buffer(&b, &bl, d_myIP);
vrpn_buffer(&b, &bl, d_myPort);
c->pack_message(32 - bl, now,
@@ -1296,7 +1296,7 @@ void vrpn_PeerMutex::sendGrantRequest (vrpn_Connection * c, vrpn_uint32 IP,
char * b = buffer;
vrpn_int32 bl = 32;
- gettimeofday(&now, NULL);
+ vrpn_gettimeofday(&now, NULL);
vrpn_buffer(&b, &bl, IP);
vrpn_buffer(&b, &bl, port);
c->pack_message(32 - bl, now,
@@ -1312,7 +1312,7 @@ void vrpn_PeerMutex::sendDenyRequest (vrpn_Connection * c, vrpn_uint32 IP,
char * b = buffer;
vrpn_int32 bl = 32;
- gettimeofday(&now, NULL);
+ vrpn_gettimeofday(&now, NULL);
vrpn_buffer(&b, &bl, IP);
vrpn_buffer(&b, &bl, port);
c->pack_message(32 - bl, now,
View
8 vrpn_Nidaq.C
@@ -52,21 +52,21 @@ vrpn_Nidaq::vrpn_Nidaq(char *pchName, vrpn_Connection *pConnection,
// call each to get them in cache
struct timeval tv, tvUpTime;
double dTime1, dTime2;
- gettimeofday(&tv, NULL);
- gettimeofday(&tv, NULL);
+ vrpn_gettimeofday(&tv, NULL);
+ vrpn_gettimeofday(&tv, NULL);
UpTime::Now();
UpTime::Now();
// Now calc offset
dTime1=UpTime::Now();
- gettimeofday(&tv, NULL);
+ vrpn_gettimeofday(&tv, NULL);
dTime2=UpTime::Now();
dTime1 = (dTime1 + dTime2)/2.0;
tvUpTime = vrpn_MsecsTimeval(dTime1*1000.0);
tvOffset = vrpn_TimevalDiff(tv, tvUpTime);
- // later, add this to tvUpTime to get into gettimeofday time frame
+ // later, add this to tvUpTime to get into vrpn_gettimeofday time frame
// alloc the daq (which also starts it up)
// args are:
View
2  vrpn_Nidaq.h
@@ -54,7 +54,7 @@ class vrpn_Nidaq : public vrpn_Analog {
private:
DAQSample daqSample;
DAQ *pDAQ;
- // value to add to UpTime calls to get into gettimeofday timeframe
+ // value to add to UpTime calls to get into vrpn_gettimeofday timeframe
struct timeval tvOffset;
// Data, threadshell, and function used by extra daq getSample thread.
View
2  vrpn_Poser.C
@@ -60,7 +60,7 @@ vrpn_Poser::vrpn_Poser (const char* name, vrpn_Connection* c) :
vrpn_BaseClass::init();
// Find out what time it is and put this into the timestamp
- gettimeofday(&p_timestamp, NULL);
+ vrpn_gettimeofday(&p_timestamp, NULL);
// Set the position to the origin and the orientation to identity
// just to have something there in case nobody fills them in later
View
4 vrpn_Poser_Analog.C
@@ -151,7 +151,7 @@ int vrpn_Poser_Analog::handle_change_message(void* userdata,
me->d_quat[1] = me->p_quat[1];
me->d_quat[2] = me->p_quat[2];
me->d_quat[3] = me->p_quat[3];
- gettimeofday(&me->vrpn_Tracker::timestamp, NULL);
+ vrpn_gettimeofday(&me->vrpn_Tracker::timestamp, NULL);
char msgbuf[1000];
vrpn_int32 len;
len = me->vrpn_Tracker::encode_to(msgbuf);
@@ -214,7 +214,7 @@ int vrpn_Poser_Analog::handle_vel_change_message(void* userdata,
me->vel_quat[1] = me->p_vel_quat[1];
me->vel_quat[2] = me->p_vel_quat[2];
me->vel_quat[3] = me->p_vel_quat[3];
- gettimeofday(&me->vrpn_Tracker::timestamp, NULL);
+ vrpn_gettimeofday(&me->vrpn_Tracker::timestamp, NULL);
char msgbuf[1000];
vrpn_int32 len;
len = me->vrpn_Tracker::encode_vel_to(msgbuf);
View
8 vrpn_RedundantTransmission.C
@@ -43,7 +43,7 @@ void vrpn_RedundantTransmission::mainloop (void) {
//fprintf(stderr, "mainloop: %d messages queued.\n", d_numMessagesQueued);
- gettimeofday(&now, NULL);
+ vrpn_gettimeofday(&now, NULL);
for (qm = d_messageList; qm; qm = qm->next) {
if ((qm->remainingTransmissions > 0) &&
vrpn_TimevalGreater(now, qm->nextValidTime)) {
@@ -190,7 +190,7 @@ int vrpn_RedundantTransmission::pack_message
d_numMessagesQueued++;
//timeval now;
-//gettimeofday(&now, NULL);
+//vrpn_gettimeofday(&now, NULL);
//fprintf(stderr, " Queued message to go at %d.%d (now is %d.%d)\n",
//qm->nextValidTime.tv_sec, qm->nextValidTime.tv_usec,
//now.tv_sec, now.tv_usec);
@@ -361,7 +361,7 @@ void vrpn_RedundantRemote::set (int num, timeval interval) {
//fprintf(stderr, "vrpn_RedundantRemote::set: %d, %d.%d\n",
//num, interval.tv_sec, interval.tv_usec);
- gettimeofday(&now, NULL);
+ vrpn_gettimeofday(&now, NULL);
d_connection->pack_message(len, now, d_protocol.d_set_type, d_sender_id,
buf, vrpn_CONNECTION_RELIABLE);
}
@@ -376,7 +376,7 @@ void vrpn_RedundantRemote::enable (vrpn_bool on) {
return;
}
- gettimeofday(&now, NULL);
+ vrpn_gettimeofday(&now, NULL);
d_connection->pack_message(len, now, d_protocol.d_enable_type, d_sender_id,
buf, vrpn_CONNECTION_RELIABLE);
}
View
2  vrpn_Router.C
@@ -572,7 +572,7 @@ vrpn_Router_Remote::vrpn_Router_Remote (const char * name,
}
- gettimeofday(&timestamp, NULL);
+ vrpn_gettimeofday(&timestamp, NULL);
}
View
4 vrpn_Serial.C
@@ -550,7 +550,7 @@ int vrpn_read_available_characters(int comm, unsigned char *buffer, int bytes,
// Find out what time it is at the start, and when we should end
// (unless the timeout is NULL)
if (timeout != NULL) {
- gettimeofday(&start, NULL);
+ vrpn_gettimeofday(&start, NULL);
time_add(start, *timeout, finish);
}
@@ -563,7 +563,7 @@ int vrpn_read_available_characters(int comm, unsigned char *buffer, int bytes,
sofar += ret;
if (sofar == bytes) { break; }
where += ret;
- gettimeofday(&now, NULL);
+ vrpn_gettimeofday(&now, NULL);
} while ( (timeout == NULL) || !(time_greater(now,finish)) );
return sofar;
View
65 vrpn_Shared.C
@@ -732,8 +732,17 @@ void get_time_using_GetLocalTime(unsigned long &sec, unsigned long &usec)
// version. It is claimed that they have fixed it now, but
// better check.
///////////////////////////////////////////////////////////////
-int gettimeofday(timeval *tp, struct timezone *tzp)
+int vrpn_gettimeofday(timeval *tp, void *voidp)
{
+#ifndef _STRUCT_TIMEZONE
+ #define _STRUCT_TIMEZONE
+ /* from HP-UX */
+ struct timezone {
+ int tz_minuteswest; /* minutes west of Greenwich */
+ int tz_dsttime; /* type of dst correction */
+ };
+#endif
+ struct timezone *tzp = (struct timezone *)voidp;
if (tp != NULL) {
#ifdef _WIN32_WCE
unsigned long sec, usec;
@@ -800,7 +809,7 @@ static int vrpn_AdjustFrequency(void)
const int tPerLoop = 500; // milliseconds for Sleep()
cerr.precision(4);
cerr.setf(ios::fixed);
- cerr << "vrpn gettimeofday: determining clock frequency...";
+ cerr << "vrpn vrpn_gettimeofday: determining clock frequency...";
LARGE_INTEGER startperf, endperf;
LARGE_INTEGER perffreq;
@@ -834,7 +843,7 @@ static int vrpn_AdjustFrequency(void)
if (fabs(perffreq.QuadPart - freq) < 0.05*freq) {
VRPN_CLOCK_FREQ = (__int64) perffreq.QuadPart;
- cerr << "\nvrpn gettimeofday: perf clock is tsc -- using perf clock freq ("
+ cerr << "\nvrpn vrpn_gettimeofday: perf clock is tsc -- using perf clock freq ("
<< perffreq.QuadPart/1e6 << " MHz)" << endl;
SetPriorityClass( GetCurrentProcess() , dwPriorityClass );
SetThreadPriority( GetCurrentThread(), iThreadPriority );
@@ -879,7 +888,7 @@ static int vrpn_AdjustFrequency(void)
// This used to check against a 200 mhz assumed clock, but now
// we assume the routine works and trust the result.
// if (fabs(freq - VRPN_CLOCK_FREQ) > 0.05 * VRPN_CLOCK_FREQ) {
- // cerr << "vrpn gettimeofday: measured freq is " << freq/1e6
+ // cerr << "vrpn vrpn_gettimeofday: measured freq is " << freq/1e6
// << " MHz - DOES NOT MATCH" << endl;
// return -1;
// }
@@ -889,10 +898,10 @@ static int vrpn_AdjustFrequency(void)
// approx the perf clock freq).
if (fabs(perffreq.QuadPart - freq) < 0.05*freq) {
VRPN_CLOCK_FREQ = perffreq.QuadPart;
- cerr << "vrpn gettimeofday: perf clock is tsc -- using perf clock freq ("
+ cerr << "vrpn vrpn_gettimeofday: perf clock is tsc -- using perf clock freq ("
<< perffreq.QuadPart/1e6 << " MHz)" << endl;
} else {
- cerr << "vrpn gettimeofday: adjusted clock freq to measured freq ("
+ cerr << "vrpn vrpn_gettimeofday: adjusted clock freq to measured freq ("
<< freq/1e6 << " MHz)" << endl;
}
VRPN_CLOCK_FREQ = (__int64) freq;
@@ -904,10 +913,10 @@ static int vrpn_AdjustFrequency(void)
// _ftime, however, has only about 6 ms resolution, so we use the peformance
// as an offset from a base time which is established by a call to by _ftime.
-// The first call to gettimeofday will establish a new time frame
+// The first call to vrpn_gettimeofday will establish a new time frame
// on which all later calls will be based. This means that the time returned
-// by gettimeofday will not always match _ftime (even at _ftime's resolution),
-// but it will be consistent across all gettimeofday calls.
+// by vrpn_gettimeofday will not always match _ftime (even at _ftime's resolution),
+// but it will be consistent across all vrpn_gettimeofday calls.
///////////////////////////////////////////////////////////////
// Although VC++ doesn't include a gettimeofday
@@ -919,7 +928,7 @@ static int vrpn_AdjustFrequency(void)
// so until then, we will make it right using our solution.
///////////////////////////////////////////////////////////////
#ifndef VRPN_WINDOWS_CLOCK_V2
-int gettimeofday(timeval *tp, struct timezone *tzp)
+int vrpn_gettimeofday(timeval *tp, void *voidp)
{
static int fFirst=1;
static int fHasPerfCounter=1;
@@ -929,6 +938,16 @@ int gettimeofday(timeval *tp, struct timezone *tzp)
static LARGE_INTEGER liDiff;
timeval tvDiff;
+#ifndef _STRUCT_TIMEZONE
+ #define _STRUCT_TIMEZONE
+ /* from HP-UX */
+ struct timezone {
+ int tz_minuteswest; /* minutes west of Greenwich */
+ int tz_dsttime; /* type of dst correction */
+ };
+#endif
+ struct timezone *tzp = (struct timezone *)voidp;
+
if (!fHasPerfCounter) {
_ftime(&tbInit);
tp->tv_sec = tbInit.time;
@@ -954,28 +973,28 @@ int gettimeofday(timeval *tp, struct timezone *tzp)
GetVersionEx(&osvi);
if (osvi.dwPlatformId != VER_PLATFORM_WIN32_NT) {
- cerr << "\nvrpn gettimeofday: disabling hi performance clock on non-NT system. "
+ cerr << "\nvrpn_gettimeofday: disabling hi performance clock on non-NT system. "
<< "Defaulting to _ftime (~6 ms resolution) ..." << endl;
fHasPerfCounter=0;
- gettimeofday( tp, tzp );
+ vrpn_gettimeofday( tp, tzp );
return 0;
}
}
// check that hi-perf clock is available
if ( !(fHasPerfCounter = QueryPerformanceFrequency( &liTemp )) ) {
- cerr << "\nvrpn gettimeofday: no hi performance clock available. "
+ cerr << "\nvrpn_gettimeofday: no hi performance clock available. "
<< "Defaulting to _ftime (~6 ms resolution) ..." << endl;
fHasPerfCounter=0;
- gettimeofday( tp, tzp );
+ vrpn_gettimeofday( tp, tzp );
return 0;
}
if (vrpn_AdjustFrequency()<0) {
- cerr << "\nvrpn gettimeofday: can't verify clock frequency. "
+ cerr << "\nvrpn_gettimeofday: can't verify clock frequency. "
<< "Defaulting to _ftime (~6 ms resolution) ..." << endl;
fHasPerfCounter=0;
- gettimeofday( tp, tzp );
+ vrpn_gettimeofday( tp, tzp );
return 0;
}
// get current time
@@ -1079,8 +1098,18 @@ void get_time_using_GetLocalTime(unsigned long &sec, unsigned long &usec)
sec -= 3054524608L;
}
-int gettimeofday(timeval *tp, struct timezone *tzp)
+int vrpn_gettimeofday(timeval *tp, void *voidp)
{
+#ifndef _STRUCT_TIMEZONE
+ #define _STRUCT_TIMEZONE
+ /* from HP-UX */
+ struct timezone {
+ int tz_minuteswest; /* minutes west of Greenwich */
+ int tz_dsttime; /* type of dst correction */
+ };
+#endif
+ struct timezone *tzp = (struct timezone *)voidp;
+
unsigned long sec,usec;
get_time_using_GetLocalTime(sec,usec);
tp->tv_sec = sec;
@@ -1100,6 +1129,6 @@ int gettimeofday(timeval *tp, struct timezone *tzp)
// do the calibration before the program ever starts up
static timeval __tv;
-static int __iTrash = gettimeofday(&__tv, (struct timezone *)NULL);
+static int __iTrash = vrpn_gettimeofday(&__tv, (struct timezone *)NULL);
#endif // VRPN_UNSAFE_WINDOWS_CLOCK
View
52 vrpn_Shared.h
@@ -12,7 +12,7 @@
#include "vrpn_Types.h"
-// Oct 2000: Sang-Uok changed becuase vrpn code was compiling but giving
+// Oct 2000: Sang-Uok changed because vrpn code was compiling but giving
// runtime errors with cygwin 1.1. I changed the code so it only uses unix
// code. I had to change includes in various files.
@@ -55,9 +55,26 @@
#endif
//--------------------------------------------------------------
-// timeval defines
+// Timeval defines. These are a bit hairy. The basic problem is
+// that Windows doesn't implement gettimeofday(), nor does it
+// define "struct timezone", although Winsock.h does define
+// "struct timeval". The painful solution has been to define a
+// vrpn_gettimeofday() function that takes a void * as a second
+// argument (the timezone) and have all VPRN code call this function
+// rather than gettimeofday(). On non-WINSOCK implementations,
+// we alias vrpn_gettimeofday() right back to gettimeofday(), so
+// that we are calling the system routine. On Windows, we will
+// be using vrpn_gettimofday(). So far so good, but now user code
+// would like to no have to know the difference under windows, so
+// we have an optional VRPN configuration setting in vrpn_Configure.h
+// that exports vrpn_gettimeofday() as gettimeofday() and also
+// exports a "struct timezone" definition. Yucky, but it works and
+// lets user code use the VRPN one as if it were the system call
+// on Windows.
+
#if (!defined(VRPN_USE_WINSOCK_SOCKETS))
#include <sys/time.h> // for timeval, timezone, gettimeofday
+#define vrpn_gettimeofday gettimeofday
#else // winsock sockets
#include <windows.h>
@@ -66,20 +83,31 @@
#endif
#include <winsock.h> // struct timeval is defined here
+ // Whether or not we export gettimeofday, we declare the
+ // vrpn_gettimeofday() function.
+ extern "C" int vrpn_gettimeofday(struct timeval *tp, void *tzp);
+
// If compiling under Cygnus Solutions Cygwin then these get defined by
// including sys/time.h. So, we will manually define only for _WIN32
+ // Only do this if the Configure file has set VRPN_EXPORT_GETTIMEOFDAY,
+ // so that application code can get at it. All VRPN routines should be
+ // calling vrpn_gettimeofday() directly.
- #ifndef _STRUCT_TIMEZONE
- #define _STRUCT_TIMEZONE
- /* from HP-UX */
- struct timezone {
- int tz_minuteswest; /* minutes west of Greenwich */
- int tz_dsttime; /* type of dst correction */
- };
- #endif
+ #ifdef VRPN_EXPORT_GETTIMEOFDAY
- // manually define this too. _WIN32 sans cygwin doesn't have gettimeofday
- extern "C" int gettimeofday(struct timeval *tp, struct timezone *tzp);
+ #ifndef _STRUCT_TIMEZONE
+ #define _STRUCT_TIMEZONE
+ /* from HP-UX */
+ struct timezone {
+ int tz_minuteswest; /* minutes west of Greenwich */
+ int tz_dsttime; /* type of dst correction */
+ };
+
+ // manually define this too. _WIN32 sans cygwin doesn't have gettimeofday
+ #define gettimeofday vrpn_gettimeofday
+ #endif
+
+ #endif
#endif
View
18 vrpn_SharedObject.C
@@ -53,7 +53,7 @@ vrpn_SharedObject::vrpn_SharedObject (const char * name, const char * tname,
if (tname) {
strcpy(d_typename, tname);
}
- gettimeofday(&d_lastUpdate, NULL);
+ vrpn_gettimeofday(&d_lastUpdate, NULL);
}
// virtual
@@ -152,7 +152,7 @@ void vrpn_SharedObject::becomeSerializer (void) {
// send requestSerializer
if (d_connection) {
- gettimeofday(&now, NULL);
+ vrpn_gettimeofday(&now, NULL);
d_connection->pack_message(0, d_lastUpdate,
d_requestSerializer_type, d_myId,
NULL, vrpn_CONNECTION_RELIABLE);
@@ -239,7 +239,7 @@ int vrpn_SharedObject::handle_requestSerializer (void * userdata,
// send grantSerializer
- gettimeofday(&now, NULL);
+ vrpn_gettimeofday(&now, NULL);
s->d_connection->pack_message(0, s->d_lastUpdate,
s->d_grantSerializer_type, s->d_myId,
NULL, vrpn_CONNECTION_RELIABLE);
@@ -267,7 +267,7 @@ int vrpn_SharedObject::handle_grantSerializer (void * userdata,
// send assumeSerializer
if (s->d_connection) {
- gettimeofday(&now, NULL);
+ vrpn_gettimeofday(&now, NULL);
s->d_connection->pack_message(0, s->d_lastUpdate,
s->d_assumeSerializer_type, s->d_myId,
NULL, vrpn_CONNECTION_RELIABLE);
@@ -422,7 +422,7 @@ vrpn_Shared_int32::operator vrpn_int32 () const {
vrpn_Shared_int32 & vrpn_Shared_int32::operator =
(vrpn_int32 newValue) {
struct timeval now;
- gettimeofday(&now, NULL);
+ vrpn_gettimeofday(&now, NULL);
return set(newValue, now);
}
@@ -832,7 +832,7 @@ vrpn_Shared_float64::vrpn_Shared_float64 (const char * name,
if (name) {
strcpy(d_name, name);
}
- gettimeofday(&d_lastUpdate, NULL);
+ vrpn_gettimeofday(&d_lastUpdate, NULL);
}
// virtual
@@ -854,7 +854,7 @@ vrpn_Shared_float64::operator vrpn_float64 () const {
vrpn_Shared_float64 & vrpn_Shared_float64::operator =
(vrpn_float64 newValue) {
struct timeval now;
- gettimeofday(&now, NULL);
+ vrpn_gettimeofday(&now, NULL);
return set(newValue, now);
}
@@ -1183,7 +1183,7 @@ vrpn_Shared_String::vrpn_Shared_String (const char * name,
if (name) {
strcpy(d_name, name);
}
- gettimeofday(&d_lastUpdate, NULL);
+ vrpn_gettimeofday(&d_lastUpdate, NULL);
}
// virtual
@@ -1208,7 +1208,7 @@ vrpn_Shared_String::operator const char * () const {
vrpn_Shared_String & vrpn_Shared_String::operator =
(const char * newValue) {