pkgsrc/databases/bdb-xml/patches/patch-ad

52 lines
1.3 KiB
Text
Raw Normal View History

$NetBSD: patch-ad,v 1.1 2008/04/03 11:18:23 joerg Exp $
Replace non-portable function with gettimeofday.
--- ../src/dbxml/HighResTimer.cpp.orig 2003-05-09 02:01:45.000000000 +0200
+++ ../src/dbxml/HighResTimer.cpp
@@ -17,8 +17,6 @@ static const char revid[] = "$Id: HighRe
#include <iostream>
#include <sstream>
-extern "C" int __os_clock(DB_ENV *, u_int32_t *, u_int32_t *);
-
using namespace DbXml;
#ifdef _MSC_VER
@@ -96,6 +94,10 @@ void HighResTimer::reset()
#else /* !_MSC_VER */
+extern "C" {
+#include <sys/time.h>
+}
+
HighResTimer::HighResTimer(const char *name, const char *what, const char *whats)
: name_(name),
what_(what),
@@ -110,14 +112,22 @@ HighResTimer::~HighResTimer()
void HighResTimer::start()
{
- (void)__os_clock(NULL, &start_secs, &start_usecs);
+ struct timeval tv;
+
+ gettimeofday(&tv, NULL);
+ start_secs = tv.tv_sec;
+ start_usecs = tv.tv_usec;
}
void HighResTimer::stop()
{
#define USECS_PER_SEC 1000000
+ struct timeval tv;
u_int32_t stop_secs, stop_usecs;
- (void)__os_clock(NULL, &stop_secs, &stop_usecs);
+
+ gettimeofday(&tv, NULL);
+ stop_secs = tv.tv_sec;
+ stop_usecs = tv.tv_usec;
duration_secs += (stop_secs - start_secs);
duration_usecs += (stop_usecs - start_usecs);
// fixup for usec under/overflow