Re: Bug#697032: rcpp: FTBFS[kfreebsd]: #error "Rcpp::Timer not supported by your OS."
On 31/12/12 17:06, Dirk Eddelbuettel wrote:
> On 31 December 2012 at 16:36, Steven Chamberlain wrote:
> | So Dirk, I think we now have this horror:
> |
> | #elif defined(linux) || defined(__linux) || defined(__FreeBSD__) ||
> | defined(__FreeBSD_kernel__) || defined(__NetBSD__) ||
> | defined(__OpenBSD__) || defined(__DragonFly__)
>
> Which is pretty much what I had committed -- modulo DragonFly. What is that for?
As in DragonFlyBSD; I don't think it defines any of the others. Not
sure about MirBSD. Maybe best to just wait until someone complains...
> https://r-forge.r-project.org/scm/viewvc.php/pkg/Rcpp/src/Timer.cpp?root=rcpp&r1=4182&r2=4181&pathrev=4182
Actually... presence of <time.h> rather depends on the libc, not the kernel?
So __GLIBC__ is perhaps more relevant than __FreeBSD_kernel__ in this
case - plus it should work for other GNU/k*BSD variants if/when they exist.
While here, I think I can explain the build failure on GNU/Hurd. The
test for __MACH__ applies to both Apple systems and GNU systems. I
suggest using mach/mach_time.h only for __APPLE__, and then adding
__GNU__ to the list for time.h
Patch attached; although I don't have a GNU/Hurd system to try it with.
Regards,
--
Steven Chamberlain
steven@pyro.eu.org
--- Timer.cpp.orig 2012-12-31 17:38:47.000000000 +0000
+++ Timer.cpp 2012-12-31 17:39:43.000000000 +0000
@@ -25,9 +25,9 @@
#if defined(_WIN32)
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
-#elif defined(__MACH__) || defined(__APPLE__)
+#elif defined(__APPLE__)
#include <mach/mach_time.h>
-#elif defined(linux) || defined(__linux) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__FreeBSD_kernel__)
+#elif defined(linux) || defined(__linux) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__GLIBC__) || defined(__GNU__)
#include <time.h>
#elif defined(sun) || defined(__sun) || defined(_AIX)
#include <sys/time.h>
@@ -49,7 +49,7 @@
return 1.0e9 * time_var.QuadPart / frequency.QuadPart;
}
-#elif defined(__MACH__) || defined(__APPLE__)
+#elif defined(__APPLE__)
nanotime_t get_nanotime(void) {
nanotime_t time;
@@ -62,7 +62,7 @@
return time * (info.numer / info.denom);
}
-#elif defined(linux) || defined(__linux) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__FreeBSD_kernel__)
+#elif defined(linux) || defined(__linux) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__GLIBC__) || defined (__GNU__)
static const nanotime_t nanoseconds_in_second = 1000000000LL;
Reply to: