mirror of
https://github.com/wfjm/w11.git
synced 2026-04-26 12:18:15 +00:00
use clock_gettime instead of gettimeofday
This commit is contained in:
@@ -17,6 +17,13 @@ software or firmware builds or that the documentation is consistent.
|
||||
The full set of tests is only run for tagged releases._
|
||||
|
||||
### Summary
|
||||
- add Rw11VirtDiskOver (simple overlay file container)
|
||||
- Rw11VirtDiskBuffer: added, disk buffer representation
|
||||
- Rw11VirtDiskOver: added, a 'keep changes in memory' overlay file container
|
||||
- Rw11Virt: add fWProt,WProt()
|
||||
- Rw11VirtDiskFile: adopt WProt handling
|
||||
- RtclRw11Unit: add fpVirt,DetachCleanup(),AttachDone(),M_virt()
|
||||
- RtclRw11UnitBase: add AttachDone()
|
||||
- tcl command handling update
|
||||
- support now sub-command handling
|
||||
- support dynamically created commands (like 'virt')
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// $Id: RlinkPortCuff.cpp 666 2015-04-12 21:17:54Z mueller $
|
||||
// $Id: RlinkPortCuff.cpp 858 2017-03-05 17:41:37Z mueller $
|
||||
//
|
||||
// Copyright 2012-2015 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
|
||||
// Copyright 2012-2017 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
|
||||
//
|
||||
// This program is free software; you may redistribute and/or modify it under
|
||||
// the terms of the GNU General Public License as published by the Free
|
||||
@@ -13,6 +13,7 @@
|
||||
//
|
||||
// Revision History:
|
||||
// Date Rev Version Comment
|
||||
// 2017-03-04 858 1.1.4 use clock_gettime instead of gettimeofday
|
||||
// 2015-04-12 666 1.1.3 add noinit attribute
|
||||
// 2014-08-22 584 1.1.2 use nullptr
|
||||
// 2013-05-17 521 1.1.1 use Rtools::String2Long
|
||||
@@ -25,13 +26,12 @@
|
||||
|
||||
/*!
|
||||
\file
|
||||
\version $Id: RlinkPortCuff.cpp 666 2015-04-12 21:17:54Z mueller $
|
||||
\version $Id: RlinkPortCuff.cpp 858 2017-03-05 17:41:37Z mueller $
|
||||
\brief Implemenation of RlinkPortCuff.
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/time.h>
|
||||
#include <time.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
@@ -492,15 +492,14 @@ libusb_transfer* RlinkPortCuff::NewWriteTransfer()
|
||||
bool RlinkPortCuff::TraceOn()
|
||||
{
|
||||
if (!fUrl.FindOpt("trace")) return false;
|
||||
struct timeval tv;
|
||||
struct timezone tz;
|
||||
struct timespec ts;
|
||||
struct tm tmval;
|
||||
|
||||
::gettimeofday(&tv, &tz);
|
||||
::localtime_r(&tv.tv_sec, &tmval);
|
||||
::clock_gettime(CLOCK_REALTIME, &ts);
|
||||
::localtime_r(&ts.tv_sec, &tmval);
|
||||
char buf[20];
|
||||
::snprintf(buf, 20, "%02d:%02d:%02d.%06d: ",
|
||||
tmval.tm_hour, tmval.tm_min, tmval.tm_sec, (int) tv.tv_usec);
|
||||
tmval.tm_hour, tmval.tm_min, tmval.tm_sec, (int) ts.tv_nsec/1000);
|
||||
cout << buf;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// $Id: RlogFile.cpp 631 2015-01-09 21:36:51Z mueller $
|
||||
// $Id: RlogFile.cpp 858 2017-03-05 17:41:37Z mueller $
|
||||
//
|
||||
// Copyright 2011-2015 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
|
||||
// Copyright 2011-2017 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
|
||||
//
|
||||
// This program is free software; you may redistribute and/or modify it under
|
||||
// the terms of the GNU General Public License as published by the Free
|
||||
@@ -13,6 +13,7 @@
|
||||
//
|
||||
// Revision History:
|
||||
// Date Rev Version Comment
|
||||
// 2017-03-04 858 2.2.1 use clock_gettime instead of gettimeofday
|
||||
// 2015-01-08 631 2.2 Open(): now with RerrMsg and cout/cerr support
|
||||
// 2014-12-10 611 2.1.2 timestamp now usec precision (was msec)
|
||||
// 2013-10-11 539 2.1.1 fix date print (month was off by one)
|
||||
@@ -23,11 +24,11 @@
|
||||
|
||||
/*!
|
||||
\file
|
||||
\version $Id: RlogFile.cpp 631 2015-01-09 21:36:51Z mueller $
|
||||
\version $Id: RlogFile.cpp 858 2017-03-05 17:41:37Z mueller $
|
||||
\brief Implemenation of RlogFile.
|
||||
*/
|
||||
|
||||
#include <sys/time.h>
|
||||
#include <time.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "boost/thread/locks.hpp"
|
||||
@@ -136,11 +137,11 @@ void RlogFile::Write(const std::string& str, char tag)
|
||||
boost::lock_guard<RlogFile> lock(*this);
|
||||
|
||||
if (tag) {
|
||||
struct timeval tval;
|
||||
::gettimeofday(&tval, 0);
|
||||
struct timespec ts;
|
||||
::clock_gettime(CLOCK_REALTIME, &ts);
|
||||
|
||||
struct tm tymd;
|
||||
::localtime_r(&tval.tv_sec, &tymd);
|
||||
::localtime_r(&ts.tv_sec, &tymd);
|
||||
|
||||
if (tymd.tm_year != fTagYear ||
|
||||
tymd.tm_mon != fTagMonth ||
|
||||
@@ -160,7 +161,7 @@ void RlogFile::Write(const std::string& str, char tag)
|
||||
<< RosPrintf(tymd.tm_hour,"d0",2) << ":"
|
||||
<< RosPrintf(tymd.tm_min,"d0",2) << ":"
|
||||
<< RosPrintf(tymd.tm_sec,"d0",2) << "."
|
||||
<< RosPrintf((int)tval.tv_usec,"d0",6) << " : ";
|
||||
<< RosPrintf((int)ts.tv_nsec/1000,"d0",6) << " : ";
|
||||
}
|
||||
|
||||
os << str;
|
||||
|
||||
Reference in New Issue
Block a user