Browse Source

linux: unbreak build if HAVE_MONOTONIC_CLOCK=0

v0.7.4-release
Ben Noordhuis 13 years ago
parent
commit
ccd8b55b01
  1. 6
      src/platform_linux.cc
  2. 17
      wscript

6
src/platform_linux.cc

@ -42,8 +42,10 @@
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <net/if.h> #include <net/if.h>
#if HAVE_MONOTONIC_CLOCK
#include <time.h> #include <time.h>
#ifndef CLOCK_MONOTONIC
# include <sys/sysinfo.h>
#endif #endif
extern char **environ; extern char **environ;
@ -296,7 +298,7 @@ int Platform::GetCPUInfo(Local<Array> *cpus) {
} }
double Platform::GetUptimeImpl() { double Platform::GetUptimeImpl() {
#if HAVE_MONOTONIC_CLOCK #ifdef CLOCK_MONOTONIC
struct timespec now; struct timespec now;
if (0 == clock_gettime(CLOCK_MONOTONIC, &now)) { if (0 == clock_gettime(CLOCK_MONOTONIC, &now)) {
double uptime = now.tv_sec; double uptime = now.tv_sec;

17
wscript

@ -380,23 +380,6 @@ def configure(conf):
have_librt = conf.check(lib='rt', uselib_store='RT') have_librt = conf.check(lib='rt', uselib_store='RT')
have_monotonic = False
if have_librt:
code = """
#include <time.h>
int main(void) {
struct timespec now;
clock_gettime(CLOCK_MONOTONIC, &now);
return 0;
}
"""
have_monotonic = conf.check_cc(lib="rt", msg="Checking for CLOCK_MONOTONIC", fragment=code)
if have_monotonic:
conf.env.append_value('CPPFLAGS', '-DHAVE_MONOTONIC_CLOCK=1')
else:
conf.env.append_value('CPPFLAGS', '-DHAVE_MONOTONIC_CLOCK=0')
if sys.platform.startswith("sunos"): if sys.platform.startswith("sunos"):
code = """ code = """
#include <ifaddrs.h> #include <ifaddrs.h>

Loading…
Cancel
Save