summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel De Graaf <danieldg@inspircd.org>2010-09-08 19:53:38 -0400
committerDaniel De Graaf <danieldg@inspircd.org>2010-09-08 20:21:15 -0400
commitbdf42d61259476c362590b9ccfb2feea33f72329 (patch)
tree59656e38a3ebbc063d1dda91b89acb966d71d183
parent6010e6b53c8f0b89718f8c883f701dcf70246660 (diff)
Add gettimeofday() fallback for systems without clock_gettime
-rwxr-xr-xconfigure3
-rw-r--r--src/inspircd.cpp10
2 files changed, 11 insertions, 2 deletions
diff --git a/configure b/configure
index e141f7969..721505fcc 100755
--- a/configure
+++ b/configure
@@ -871,6 +871,9 @@ print FILEHANDLE "#define MAXBUF " . ($config{MAXBUF}+2) . "\n";
if ($config{HAS_EVENTFD} eq 'true') {
print FILEHANDLE "#define HAS_EVENTFD\n";
}
+ if ($config{OSNAME} !~ /DARWIN/i) {
+ print FILEHANDLE "#define HAS_CLOCK_GETTIME\n";
+ }
my $use_hiperf = 0;
if (($has_kqueue) && ($config{USE_KQUEUE} eq "y")) {
print FILEHANDLE "#define USE_KQUEUE\n";
diff --git a/src/inspircd.cpp b/src/inspircd.cpp
index b4a013e50..47a9fabba 100644
--- a/src/inspircd.cpp
+++ b/src/inspircd.cpp
@@ -344,8 +344,7 @@ InspIRCd::InspIRCd(int argc, char** argv) :
this->Res = 0;
this->ConfigThread = NULL;
- // Initialise TIME
- clock_gettime(CLOCK_REALTIME, &TIME);
+ UpdateTime();
this->startup_time = TIME.tv_sec;
// This must be created first, so other parts of Insp can use it while starting up
@@ -693,7 +692,14 @@ InspIRCd::InspIRCd(int argc, char** argv) :
void InspIRCd::UpdateTime()
{
+#ifdef HAS_CLOCK_GETTIME
clock_gettime(CLOCK_REALTIME, &TIME);
+#else
+ struct timeval tv;
+ gettimeofday(&tv, NULL);
+ TIME.tv_sec = tv.tv_sec;
+ TIME.tv_nsec = tv.tv_usec * 1000;
+#endif
}
int InspIRCd::Run()