ports/textproc/randlm/files/patch-src-LDHT-Util.h
Piotr Kubaj 2988f607ed textproc/randlm: fix build on powerpc*
rdtsc() is available only on amd64 / i386.
2022-02-21 11:30:36 +00:00

31 lines
915 B
C++

--- src/LDHT/Util.h.orig 2012-03-30 10:53:05 UTC
+++ src/LDHT/Util.h
@@ -10,6 +10,10 @@
#include <cstdlib>
#include <cstring>
#include <stdint.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
#define V(expr) std::cerr << __FILE__ << ":" \
<< __LINE__ << " " \
@@ -43,6 +47,9 @@ class Util { (public)
static uint64_t hash(uint64_t a, uint64_t b, uint64_t P, uint8_t* e);
static uint64_t hash(uint64_t a, uint64_t b, uint64_t P, uint64_t e);
static inline uint64_t rdtsc() {
+#if defined(__powerpc__)
+ return __builtin_readcyclecounter();
+#else
uint32_t lo, hi;
__asm__ __volatile__(
"xorl %%eax,%%eax\n"
@@ -52,6 +59,7 @@ class Util { (public)
:
: "%ebx", "%ecx");
return static_cast<uint64_t>(hi) << 32 | lo;
+#endif
};
};